Hello,
This for loop is not working, it doesn't even print anything.
Why isn't it working? If it's not the correct method then what do I need to do? FireAllClients and use a local script?
local plrs = game.Players:GetPlayers() -- Also tried :GetChildren() for i,v in pairs(plrs) do local Spawn = game.Workspace[currentMap.Name].Spawn print(currentMap.Name) v.Character.Torso.CFrame = CFrame.new(Spawn.Position) Spawn:Destroy() v.Character.Humanoid.Walkspeed = 0 wait() print(v.Name) end
I also tried the
for i = 1,#plrs do local Spawn = game.Workspace[currentMap.Name].Spawn print(currentMap.Name) plrs[i].Character.Torso.CFrame = CFrame.new(Spawn.Position) Spawn:Destroy() plrs[i].Character.Humanoid.Walkspeed = 0 wait() print(v.Name) end
I'm not really quite sure why it doesn't work, but I'll provide a script that I think will work.
for i,v in pairs(game:GetService('Players'):GetChildren()) do local Spawn = game.Workspace:FindFirstChild(currentMap.Name):FindFirstChild('Spawn') local Character = v.Character or v.CharacterAdded:Wait() print(currentMap.Name) Character:FindFirstChild('HumanoidRootPart').CFrame = CFrame.new(Spawn.Position) Spawn:Destroy() Character:FindFirstChildOfClass('Humanoid').Walkspeed = 0 wait() print(v.Name) end