Roblox interview question

How did you strategize to optimize this task?