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

Disabling Player Controls, not working why?

Hello fellow developers,

I'm working for a cutscene and so I have to disable player controls through PlayerModule. I don't use walkspeed & jump height method because I am also moving the humanoid to another position, setting walkspeed to 0 will ruin it.

My problem: Sometimes the controls are disabled, sometimes not and I'm looking to fix that.

This is the code:

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

local Controls = PlayerModule:GetControls()

Controls:Disable()

This is the error I'm getting:

Player:Move called, but player currently has no humanoid.

Any help is appreciated, thank you.

2 comments

0

Is this a server script or local script?

0

It's in a local script, yep

1 answer

✓ Accepted answer

Although I have no experience with PlayerModule, I think that the problem is happening because the player is moving while the script is executing, and it seems to be interfering with your code. Try perhaps anchoring the Player's HumanoidRootPart before halting all of the player's movement, and unanchoring the HumanoidRootPart when the cutscene is finished.

9 comments

0

Hello, thank you for answering! Anchoring HumanoidRootPart cancelled the MoveTo function, that didn't worked well.

0

Hello, sorry for the late reply back, but perhaps changing the HumanoidRootPart's position instead of using MoveTo might work.

0

@Oxprem Hello, thank you for answering back! Sadly, tried your advice but it's not working. Interestingly, I moved the local script in StarterPlayerScripts and now it says "character" instead of "humanoid". Do you think this is sort of a ROBLOX bug or I'm doing something bad? Thank you for helping me out!

0

Hey, coming back after a random try, instead of moving it to StarterPlayerScripts; I've moved it to StarterCharacterScripts and the warning is not showing up anymore but now it doesn't work at all! It works in studio but not live.

0

Did you make sure you published the game to Roblox?

0

Okay, so I published once again to make sure everything is good at all. No errors showing up but once again it sometimes works, sometimes not. Must be a bug?

0

Wait, so I tried once again live, at first it doesn't work but as soon as I reset my character it works, the controls are disabled, why is that?

0

Update ~ I've removed the "WaitForChild" function and instead of that I've set a wait function for 2 seconds and now it works perfectly, as I wanted. I have no idea why but it is. Thank you for helping me out with this! Have a nice day!

0

Sorry I haven't responded, but thank you for accepting my answer!

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