How would I make a player unable to move on join, but not on reset

I want to make it so that the player cannot move until they press a button on join, how would I make the player freeze until they press the button? The button is a UI. I do NOT want to freeze them on reset.

I have no idea how to access the humanoid on join using a button.

Thanks!

2 Likes

Set their walkspeed to 0 on join and then back to 16 when t hey press t he button, and put this localscript in somewhere where it wont be replicated, like in StarterPlayerScripts, or, what I recommend, a ScreenGui with ResetOnSpawn Disabled

i made so many typos holy

Since everyone’s mentioning t heir examples, here’s how I would do it. Localscript in the button itself with the ScreenGui’s ResetOnSpawn to disabled

local button = script.Parent
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

hum.WalkSpeed = 0

button.MouseButton1Click:Connect(function()
	hum.WalkSpeed = 16
end)
1 Like

Local script
Put this in a local script in StarterPlayer scripts. Make sure to define the text button.

local player = game.Players.LocalPlayer

local controls = require(player.PlayerScripts.PlayerModule):GetControls()

local button = --define button

local char = player.Character or player.CharacterAdded:Wait()
controls:Disable()

button.Activated:Connect(function()
      controls:Enable()
end)

Can’t you just change the Humanoid's WalkSpeed to 0 in a LocalScript on StarterPlayerScripts?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local PlayerGui = Player:WaitForChild("PlayerGui")

local Button = PlayerGui:WaitForChild("ScreenGui").Button

Humanoid.WalkSpeed = 0

Button.MouseButton1Click:Connect(function()
    Humanoid.WalkSpeed = 16
end)

My brain has fried ok

1 Like

I don’t think it’s needed to disable the controls like that, since they could just set the WalkSpeed to 0 at join and then 16 when the button is pressed

Also, @JackscarIitt you forgot to set the WalkSpeed to 16 in the event!

True, I think either works fine. Setting the controls is better because if they reset with your code, they will have the walk speed again without pressing the button.

1 Like

What would

mean?
It’s giving me an error at the moment. I only want the player to be frozen when they first join.

He meant to do

local Character = Player.Character or Player.CharacterAdded:Wait()

If the player’s character doesn’t exist in that moment, it waits for it to exist before continuing

1 Like

make players speed 0 when they join using player ADDDED this will freeze player only when they join

Again, it depends on the location of it. Personally, WalkSpeed set to 0 at first and then to 16 when button is pressed in a LocalScript inside of a button inside of a ScreenGui with ResetOnSpawn disabled would be an ideal way to do it, but programming has many solutions for the same thing haha!

2 Likes

Thanks everyone, but the script that helped me out the most was from @JackscarIitt so I set that as the solution.

Happy developing!

2 Likes