hi, im kinda struggling on this script like when i use for i,v in pairs on the humanoid.WalkSpeed, the speed wont change to 0, idk why am i do it wrong or should i not using for i,v in pairs? heres the script
for i,v in pairs(game.Players:GetPlayers()) do local char = v.Character local hum = char:FindFirstChild("Humanoid") hum.WalkSpeed = 0 wait(3) hum.WalkSpeed = 16 end
btw wat i want to achive is, when the match isnt starting then all players in the match cant move or disable movement, but when the match is starting all players can walk normaly, any ideas?
Okay so i have a script that gets all the players and checks if there is an object in Workspace that also has their name, if yes then the walkSpeed of the player goes to 0 then back to 16.I tested in studio of course and it worked so it should work for you too.Also when i ran your code in studio I got an error saying attempt to index nil with find first child, I still dont know why you cant just say v.Character but oh well.
Oh yeh and this is the code:
--Script(Server) local tab=game.Players:GetChildren() for i,p in pairs(tab) do local gtab=game.Workspace:GetChildren() for i,v in pairs(gtab) do if p.Name==v.Name then print(v.Name) v.Humanoid.WalkSpeed=0 wait(3) v.Humanoid.WalkSpeed=16 end end end
for i,v in pairs(game.Players:GetPlayers()) do local char = v.Character or v.CharacterAdded:Wait() local hum = char:FindFirstChild("Humanoid") hum.WalkSpeed = 0 wait(3) hum.WalkSpeed = 16 end