Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can I disable RenderStepped?

I have a RenderStepped function that keeps the MouseBehavior locked at center because that's the only way it seems to work for me in-game. But i'm trying to figure out a way to disable it and re-enable it so the player can access in-game guis

main.run.RenderStepped:Connect(function()
	main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter
end)

2 answers

✓ Accepted answer

You could also try disconnecting.

local function myfunction ()
	main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter
end
local connection = main.run.RenderStepped:Connect(myfunction)

--connection:Disconnect

1 comment

0

Thank you, this is the method that worked for me.

All you need is to add a check with a bool value that you change whenever you want the mouse to be free.

Something that looks like this

local inGui = false

main.run.RenderStepped:Connect(function()
    if not inGui then
    	main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter
    end
end)

Now let us say you want to make the mouse free again to be able to access the UIs

All you need to do is run this line:

inGui = true

Then when you want it locked again run this line:

inGui = false 

That's it, if you have any questions please let me know.

1 comment

0

Thank you, it may be a lack of experience of something so simple on my side as to why it didn't work for me, but this was a great answer as well.

This discussion is preserved as it was. New answers, comments, and votes are closed.