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.
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)
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)
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.
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!