I'm building a tool that selects a block if it has a certain name. I've hooked the function that accomplishes this up to RenderStepped, but I feel like this is an inefficient way of doing it. It feels unnecessary to do this 60 times per second. Is there a better way to accomplish this? Hooking the function up to mouse.Move and camera.Changed doesn't work either, because if, say, another player moves in front of the player's mouse, the selectionbox's adornee won't update (to nil). Thanks.
function updateSelectionBox()
if mouse.Target then
if mouse.Target.Name == "Boundary" or mouse.Target.Name == "Object" then
selectionBox.Adornee = mouse.Target
else
selectionBox.Adornee = nil
end
end
end
RunService.RenderStepped:connect(updateSelectionBox)

2 comments
you could do wait(0.1). A bunch of people probably wont even notice
you could use UserInputService for this