game.ReplicatedStorage.ShowGui2.OnClientEvent:Connect(function()
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char.Humanoid
h.WalkSpeed = 0
wait(18)
h.WalkSpeed = 10
end)
If the player’s character already exists, it will wait forever until the player respawns.
game.ReplicatedStorage.ShowGui2.OnClientEvent:Connect(function()
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local h = char:FindFirstChildOfClass("Humanoid") or char:WaitForChild("Humanoid")
-- get the humanoid or wait for it to exist
h.WalkSpeed = 0
wait(18)
h.WalkSpeed = 10
end)