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

How do I Disable Player Movement?

Asked by
Sulu710 142
5 years ago

I want to make a script that will disable the player's ability to move their character, but still allow other scripts to move the character. I tried setting the character's walkspeed to 0, but then I couldn't move it with my own scripts. I was wondering if there's some sort of function I could use to basically disable WASD. Thank you for reading!

2 answers

Log in to vote
1
Answered by
Farsalis 369 Moderation Voter
5 years ago
Edited 5 years ago

Here you go:

This Is From A Local Script Inside Of StarterPlayerScripts

local MC = require(game:GetService("Players").LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("ControlModule"))
MC:Disable()
0
lol Farsalis 369 — 5y
0
Oh no I don't know which one to accept :( Sulu710 142 — 5y
Ad
Log in to vote
1
Answered by
pwx 1581 Moderation Voter
5 years ago

Best way to go about it is disable the core controls script.

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()
0
If I then used that script and said controls:Enable() will it go back to normal? Sulu710 142 — 5y
0
Aye. It should. pwx 1581 — 5y
0
Thank you! Sulu710 142 — 5y

Answer this question