I have a piece of code that use Mouse.Move event to activated a function, which highlights the part you are currently aiming at with your cursor. This however creates an issue, where if I were not to move my mouse, the highlight would stay on the part even if its outside of the cursor. I was wondering if I could fix it somehow. Would I need to loop the said function?
Yeah, sort of. You would probably need to put it in a RenderStepped connection instead of a Move connection.
Thank you, but how would I write it down? something like workspace.RenderStepped:Connect? Or is there something else that should be in the place of workspace
*I think its RunService?
You’d want to use RunService, not workspace. So it’d look like this:
game:GetService("RunService").RenderStepped:Connect(function()
-- your code here
end)
Just make sure you’re using RenderStepped only on the client, since it’s a client-only event. If you’re scripting on the server, you’d want to use Heartbeat instead.
Is Heartbeat exactly the same as RenderStepped with only difference being the client or server behavior?
They’re close, but not exactly the same.
-
RenderStepped: fires before the frame renders and this is only available for clients.
https://create.roblox.com/docs/reference/engine/classes/RunService#RenderStepped -
Heartbeat: fires after physics simulation and can be run on both the client and server.
https://create.roblox.com/docs/reference/engine/classes/RunService#Heartbeat
Haha you beat me to it! I was writing the same thing.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.