Script only working in Studio

Hello! This here script is meant to disable the user’s controls whilst they are in the character customization menu. Works flawlessly in Studio, but when I go into test it doesn’t work for me or my testers.

Here is the script:

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

game.Players.PlayerAdded:Connect(function(main)
    Controls:Disable()
end)

Could anyone pinpoint the issue? It’s a local script in StarterGui.

Thank you very much!

1 Like

When you say Test, do you mean in the actual game on Roblox or via Studio testing?

ROBLOX studio testing.

30characterlimit

And have you tried it in game?

Hmmm I think it’s a localscript because he used LocalPlayer, but using game.PlayerAdded on the local side doesn’t work I don’t think. It could be server only, but it’s not something you use commonly in a LocalScript

Yes. Just made a discovery; when I join, it doesn’t work, but when my friend joined I was frozen but he was not.

Oh if you’re trying to freeze people you can also set their Walkspeed and jump power to 0

I never thought of that lmao, thanks

As @HilyrHere said, you want to freeze a certain person it is simple to change their Walkspeed and JumpPower both to 0 via scripts but I’m no scripting master so you’d be better off asking him.

Ah, if it solved the problem for you you can mark my answer as the solution

Well, there’s still the issue of how I’m going to do that. Do I just make a local script that changes walkspeed for the local player’s humanoid? Where do I put the local script?

This happens becuase the script is executed after the player is added, so the event PlayerAdded does not fire for that player.

To solve the problem change

game.Players.PlayerAdded:Connect(function(main)
    Controls:Disable()
end)

to

Controls:Disable()

You just make a Localscript, put it StarterCharacterScripts and get the humanoid and set it’s Walkspeed and Jump power to 0

You can do character related stuff on the client and it will replicate to server without remotevents as that’s how the character works. (as far as I know)