Help with mouse target

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.

1 Like

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.

1 Like

Is Heartbeat exactly the same as RenderStepped with only difference being the client or server behavior?

They’re close, but not exactly the same.

2 Likes

Haha you beat me to it! I was writing the same thing.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.