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

Disabling player movement (without changing walkspeed and jumppower)?

So I recently came across this script and it was working perfectly

local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

-- In order to access controls, you must first get the controls
local Controls = PlayerModule:GetControls()
-- For Cameras, use PlayerModule:GetCameras()

--[==[ You have now obtained the new control methods! Yay! ]==]--

-- In order to enable controls, you need to use the reference Controls instance and call the Enable method within it.
--Controls:Enable()

-- In order to disable controls, you need to use the reference Controls instance and call the Disable method within it
Controls:Disable()
script.Disabled = true

I had a separate script that reenables the controls and when I tested it it worked perfectly, I test it again a few days later and only DISABLING works, reenabling doesn't and it stays disabled but no errors or messages come up in Output, how would I disable the player movements so I can do a cutscene for my game? I want to have the player walk around so messing with walkspeed isn't an option

3 comments

0

You put this in a local script?

0

It works for me, so put all this code in a local script inside StarterGui or StarterPlayerScripts

0

It's in a LocalScript in StarterGui

1 answer

✓ Accepted answer
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

-- In order to access controls, you must first get the controls
local Controls = PlayerModule:GetControls()
-- For Cameras, use PlayerModule:GetCameras()

--[==[ You have now obtained the new control methods! Yay! ]==]--

-- In order to enable controls, you need to use the reference Controls instance and call the Enable method within it.
--Controls:Enable()

-- In order to disable controls, you need to use the reference Controls instance and call the Disable method within it
Controls:Disable()
wait(5)
Controls:Enable()

There is a function that allows you to re-enable it (Controls:Enable). I hope this helps!

3 comments

0

This is the original script I used and it worked the first time I used it, so I moved the Enabling part to a separate script and it still worked fine, when I tried it a few days later enabling it suddenly doesn't work anymore even within the same script and no errors come up

0

Update: It works but if I disable the script then suddenly the movement gets disabled again

0

Got it to work properly by adding a BoolValue to check if Movement can be reenabled and created a local while true do function that checks for this

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