New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
3

# How do I disable a player's control?

Nickelz 37
10 months ago

I am trying to make a cutscene that includes a player walking to a point and such, but I cannot do that if the player decides to move by pressing the A,W,S,D keys or the arrow buttons. I used to use this:

--LocalScript
local control = script.Parent:WaitForChild("ControlScript")
function Stop()
control.Parent = nil
end
function Resume()
control.Parent = script.Parent
end
wait()
Stop()
wait(1000)
Resume()


but aparently that is outdated and roblox uses module scripts to control that sort of stuff now, so I looked around and I found this:

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


and I pasted that into a local script inside StarterPlayerScripts without any outcome. Am I doing something wrong?

0
i tested it in a blank baseplate and it worked perfectly? (player module:Disable() method) the8bitdude11 322 — 10mo

1
Kulh 125
10 months ago
Edited 10 months ago

Oops!! I did some testing, and found that the server cannot see the PlayerScripts folder!

This means you need to get the PlayerScripts folder in a local script, and fire it to the server script using a RemoteFunction!!

Here is what I came up with:

What you need:

RemoteEvent named "SendPlayerModule" located in ReplicatedStorage. Server-sided Script, located in ServerScriptService. Local-Script, located in StarterPlayerScripts.

Server script:

function playerFirstJoins(player)
local event = game:GetService("ReplicatedStorage"):FindFirstChild("SendPlayerModule")
local playa = player
event:FireClient(player,playa)
end



Local-Script:

local event = game:GetService("ReplicatedStorage"):FindFirstChild("SendPlayerModule")

event.OnClientEvent:Connect(function(playa)
if playa.Name == game.Players.LocalPlayer.Name then
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
Controls:Disable()
else
return
end

end)