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
4 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
4 years ago
Edited 4 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 — 4y
0
Oh no I don't know which one to accept :( Sulu710 142 — 4y
Ad
Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 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 — 4y
0
Aye. It should. pwx 1581 — 4y
0
Thank you! Sulu710 142 — 4y

Answer this question