Hi so I have hundreds of parts and I want to change the color of the part (locally) that the mouse is over. Would it be best to do this in a while loop and check player:GetMouse().Target or is there a better alternative?
Someone told me while loops are unefficient, his argument was “You’re always one task.wait() away from game failure”.
The better way is to use an event
local mouse = player:GetMouse()
mouse.Move:Connect(function()
if mouse.Target:IsA("Part") and mouse.Target ~= nil then
-- Do whatever you want with the mouse.Target
end
end)
2 Likes
yea thats a lot better than a while loop thank you
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.