local players = game:GetService("Player"):GetPlayers()
players.FindFirstChild("Humanoid").WalkSpeed = 0
players.FindFirstChild("Humanoid").JumpPower = 0
wait(IntermissionLength)
players.FindFirstChild("Humanoid").WalkSpeed = 16
players.FindFirstChild("Humanoid").JumpPower = 50
You’re on the right track, but there’s a couple of problems.
First, you find the Humanoid inside the player’s character, not the player object.
Second, you need to loop through all of the current players in the game. With your logic, it’s like your only trying to set the speed of one player.
To fix this, we can create a for loop that iterates through each child of the Players service:
local players = game:GetService("Player"):GetPlayers() -- Creates a table of all current players.
-- Loop through ALL players and set each Humanoid's walk speed and jump power to 0.
for _, player in pairs (players) do
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
end
wait(IntermissionLength) -- Wait for set length.
-- Loop through ALL players AGAIN. Reset values to their defaults.
for _, player in pairs (players) do
player.Character.Humanoid.WalkSpeed = 16
player.Character.Humanoid.JumpPower = 50
end
Let me know if you have any questions.
5 Likes
Thank you very much. As someone who is just getting into programming, this helped me a lot!
1 Like