Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can I disable RenderStepped?

Asked by 4 years ago

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

Log in to vote
0
Answered by
CjayPlyz 643 Moderation Voter
4 years ago

You could also try disconnecting.

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

--connection:Disconnect
0
Thank you, this is the method that worked for me. Revisedy 23 — 4y
Ad
Log in to vote
1
Answered by
Nanomatics 1160 Moderation Voter
4 years ago

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.

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. Revisedy 23 — 4y

Answer this question