So basically I wan’t it so when the player joins his/her walkspeed is set to 0 until they click the play button. I’ve tried doing this myself however it just doesn’t work somehow.
I have a sever script with the following code in it:
game.Players.PlayerAdded:Connect(function(plr)
plr.Character.Humanoid.Walkspeed = 0
end)
4 Likes
L2000
(Wiggles)
February 17, 2020, 7:18pm
#2
You need to wait for the character to load before you can do anything with that. You can use the CharacterAdded event:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
character.Humanoid.Walkspeed = 0
end)
end)
2 Likes
Still did not work. No errors but the players walkspeed is still the default.
1 Like
Adding on to what @ThomasChabot said, you would also want to wait for the humanoid to spawn in of course
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local hum = character:WaitForChild(“Humanoid”)
hum.WalkSpeed = 0
end)
end)
2 Likes
Thank you!!. This worked very well.
How do I fix this so it doesn’t reset and change the players walkspeed back to 0 when he/she dies or resets?
Cadentopia
(Cadentopia)
February 17, 2020, 7:51pm
#7
You could add a Humanoid.Died event to wait for the character to respawn, and then change their walkspeed.
The example code below covers it.
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
local Char = workspace:WaitForChild(Player.Name)
if Char ~= nil then
Char:WaitForChild("Humanoid").WalkSpeed = 0
end
end)
end)
1 Like
I put that in the script and nothing happened. The walkspeed is default now.
Cadentopia
(Cadentopia)
February 17, 2020, 8:08pm
#9
Oh, my bad. I overcomplicated my code a bit. Try this.
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
repeat wait() until Character ~= nil -- ik it's inefficient.
Character:WaitForChild("Humanoid").WalkSpeed = 0
end)
end)
It stills sets the players walkspeed to 16/default. https://gyazo.com/a74a2f361dc0abddba91f825b450489e
No errors in dev console though.
desuhookvw
(desuhookvw)
February 17, 2020, 8:11pm
#11
What is the point of making a script for it? You can just change it in StarterPlayer service properties.
1 Like
Cadentopia
(Cadentopia)
February 17, 2020, 8:12pm
#12
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").WalkSpeed = 0
end)
end)
Cadentopia
(Cadentopia)
February 17, 2020, 8:13pm
#13
It’s only useful if the WalkSpeed is planned to change at some point.
(i.e I wouldn’t imagine @danthespam permanently making players stuck, in this case anyway)
1 Like
Yes. Also the code above still didn’t work.
Cadentopia
(Cadentopia)
February 17, 2020, 8:15pm
#15
try the code again. i edited it YET again
There is a property in StarterPlayer called “CharacterWalkSpeed”. This could potentially be useful for your inquiry.
2 Likes
Your code worked but it still resets back to 0 once the player has died or resets
I only wan’t the players walkspeed to be 0 once.
Cadentopia
(Cadentopia)
February 17, 2020, 8:17pm
#19
game.Players.PlayerAdded:connect(function(Player)
local CA
CA = Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").WalkSpeed = 0
CA:Disconnect()
end)
end)
3 Likes
This code worked. Thank you very much!
1 Like