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

Disabling Player Controls, not working why?

Asked by 3 years ago
Edited 3 years ago

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.

0
Is this a server script or local script? Oxprem 140 — 3y
0
It's in a local script, yep Alisa_xd1 8 — 3y

1 answer

Log in to vote
0
Answered by
Oxprem 140
3 years ago

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.

0
Hello, thank you for answering! Anchoring HumanoidRootPart cancelled the MoveTo function, that didn't worked well. Alisa_xd1 8 — 3y
0
Hello, sorry for the late reply back, but perhaps changing the HumanoidRootPart's position instead of using MoveTo might work. Oxprem 140 — 3y
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! Alisa_xd1 8 — 3y
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. Alisa_xd1 8 — 3y
View all comments (5 more)
0
Did you make sure you published the game to Roblox? Oxprem 140 — 3y
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? Alisa_xd1 8 — 3y
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? Alisa_xd1 8 — 3y
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! Alisa_xd1 8 — 3y
0
Sorry I haven't responded, but thank you for accepting my answer! Oxprem 140 — 3y
Ad

Answer this question