Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 03:55 PM |
Trying to change the player's walkspeed to 0 for a reason... Currently I have it wait 3 seconds, but how can I make it so as soon as the player is loaded the walkspeed changes?
wait (3) for i,v in pairs(game.Players:GetPlayers()) do v.Character.Humanoid.WalkSpeed = 0 |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 03:58 PM |
Idk if you want it as soon as they respawn but here is a localscript that'll cover that
player = game.Players.LocalPlayer
char = player.Character or player.CharacterAdded:wait()
char:WaitForChild("Humanoid").WalkSpeed = 0 |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:06 PM |
Tried this and it didn't work
for i,v in pairs(game.Players:GetPlayers()) do v:WaitForChild("Humanoid").WalkSpeed = 0
How can I fix that? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:10 PM |
Is it because there's no "end"?
wait (3) for i,v in pairs(game.Players:GetPlayers()) do if v.Character then v.Character:WaitForChild("Humanoid").WalkSpeed = 0 end end |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 06 Apr 2015 04:11 PM |
| repeat wait() until player:FindFirstChild("Humanoid") |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:15 PM |
Tried
for i,v in pairs(game.Players:GetPlayers()) do repeat wait() until v:FindFirstChild("Humanoid") v.Humanoid.WalkSpeed = 0
And it didn't work. And the reason there's no end is because this is part of a larger script and the end is at the bottom of it. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:16 PM |
| Ray, your way didn't work either. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:20 PM |
| Nope. Would my whole script help? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:20 PM |
| Probably, I don't see anything wrong here |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:22 PM |
Here, it is a map script:
local GameState = game.Workspace.GameState
for i,v in pairs(game.Players:GetPlayers()) do --Your code if v.Character then v.Character:WaitForChild("Humanoid").WalkSpeed = 0
while wait() do
Maps = game.ServerStorage.Maps:GetChildren() ranGame = math.random(1, #Maps) gameChosen = Maps[ranGame] wait (5)
gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace gameChosenClone:MakeJoints() GameState.Value = "NewRound" wait (10)
GameState.Value = "Normal" game.Workspace.Music: Play() wait(30) --420
for index,player in next, game.Players:GetPlayers() do player.Character:MoveTo(game.workspace.Spawn1.Position) end gameChosenClone:Remove() game.Workspace.Music: Destroy()
GameState.Value = "EndRound" wait(120)
end end end |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:23 PM |
| I put it in a script by itself and it didn't work either. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:25 PM |
| Apparently the script doesn't even start, because I tried prints and nothing printed. So I'm assuming that was an incorrect way of doing it? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:27 PM |
| put your for loop inside the while loop. Right now, your for loop is only running once, probably when your character hasn't even loaded yet. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:28 PM |
@ray I don't want it to fire every time though, I just want it so when the player joins the server their walkspeed is changed until everything is up and running. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:38 PM |
Nevermind, I'm pretty sure this worked:
for index,player in next, game.Players:GetPlayers() do print ("Loaded") player.Character:WaitForChild("Humanoid").WalkSpeed = 0 end |
|
|
| Report Abuse |
|
|