I realize a topic similar to this has been created a million times, and I have looked at each one, but I can’t disable player controls. Here is my script:
local playerScripts = plr:WaitForChild("PlayerScripts")
local playerModule = playerScripts:WaitForChild("PlayerModule")
local controlModule = require(playerModule)
local controls = controlModule:GetControls()
Here is where I’m trying to get the controls. The error I’m getting is that there is infinite yield to get the PlayerScripts. How can I fix this?
Is there a reason you couldn’t just set JumpPower and WalkSpeed to 0? For example, if you’re making a cutscene where the player is moving and you don’t want there input to interrupt there cutscene, then you couldn’t do this, but in general usually you can just set WalkSpeed and JumpPower/JumpHeight to 0.
Fair point. Because the client always has control of it’s WalkSpeed, JumpPower and if it’s anchored if you want to be extra secure try the following instead. This uses ContextActionService. I forget where I found this method but I’ve been using it for awhile without issue.
local CAS = game:GetService("ContextActionService")
local FREEZE = "freezeMovement"
CAS:BindAction(FREEZE, function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems())) -- freeze
task.wait(4) -- however long you want the player to be frozen
CAS:UnbindAction(FREEZE) -- unfreeze
I don’t think I can do that because I want to disable movement because I am animating the character. Could I still do that without disturbing the animation?
It is kind of an emote, but not exactly. It essentially functions the same way as an emote. I just want to stop the player so I can animate them doing an action.
You are still able to play your animations normally even if the HumanoidRootPart is anchored.
Do note that if your making an animation where the player walks from point A to point B that would require you teleport the HRP to the destination after your animation stops
I been doing this since day 1, the only problem with this is that if the player is running and you anchor them, the animation for the running will still be slightly playing
I mean, you could just do a :FireClient as well to use CAS, but that might seem unnecessary honestly.
If this is on the server and you want to keep it on the server, the only real options you could explore here are JumpPower + Walkspeed editing, or anchoring the HumanoidRootPart. Both have fundamental flaws here and disadvantages which code hinder the progress of your animation, especially if it requires the user to walk somewhere.
I mean, you could just do a :FireClient as well to use CAS, but that might seem unnecessary honestly.
If this is on the server and you want to keep it on the server, the only real options you could explore here are JumpPower + Walkspeed editing, or anchoring the HumanoidRootPart. Both have fundamental flaws here and disadvantages which could hinder the progress of your animation, especially if it requires the user to walk somewhere.