I’m working on this main script for a game, and this part of the code has an issue I can’t seem to fix.
for i,v in pairs(game.Players:GetChildren()) do
if v.role.Value == "Guard" then
v.Character:MoveTo(game.Workspace.GuardSpawn.Position + Vector3.new(0, 4, 0))
for i,x in pairs(game.ServerStorage.TeamTools.Guard:GetChildren()) do
x:Clone().Parent = v.Backpack
end
end
if v.role.Value == "Robber" then
v.Character:MoveTo(game.Workspace.RobberSpawn.Position + Vector3.new(0, 4, 0))
for i,x in pairs(game.ServerStorage.TeamTools.Robber:GetChildren()) do
x:Clone().Parent = v.Backpack
end
end
if v.role.Value == "Worker" then
--v.Character:MoveTo(game.Workspace.WorkerSpawn.Position + Vector3.new(0, 4, 0))
for i,x in pairs(game.ServerStorage.TeamTools.Worker:GetChildren()) do
x:Clone().Parent = v.Backpack
end
end
if v.role.Value == "Civillian" then
--v.Character:MoveTo(game.Workspace.CivillianSpawn.Position + Vector3.new(0, 4, 0))
for i,x in pairs(game.ServerStorage.TeamTools.Civillian:GetChildren()) do
x:Clone().Parent = v.Backpack
end
end
if v.role.Value == "" or nil then
warn(v.Name.. " has no role")
end
game.ReplicatedStorage.Remotes.RoleInfo:FireAllClients()
wait(50000)
end
The first player the script loops through will have their items and be teleported correctly, but any other players after them never receive their items or get teleported.
Nothing of interest is in the output, and I’m stumped. Does anyone know why this is happening?
The other players do have their roles and receive the RoleInfo event correctly.