so i'm having trouble teleporting all the players to a position of a part.
my code
while true do local status = game.ReplicatedStorage.Status local inter = game.ReplicatedStorage.Intermission status.Value = "Time until next round: " local plr = game.Players.LocalPlayer inter.Value = 30 repeat inter.Value -= 1 wait(1) until inter.Value == 0 local Josh = game.ReplicatedStorage.Spawn:Clone() Josh.Parent = workspace game.Players.LocalPlayer.Character.HumanoidRootPart.Position = Josh.SpawnPoint.Position plr.Humanoid.WalkSpeed = 0 status.Value = "" inter.Value = 3 wait(1) inter.Value = 2 wait(1) inter.Value = 1 wait(1) inter.Value = 0 status.Value = "Go!" wait(1) status.Value = "" Josh:Destroy() plr.Humanoid.WalkSpeed = 16 end
can you guys help? this is a server script btw
to get all players use for loop to get all players
while true do local status = game.ReplicatedStorage.Status local inter = game.ReplicatedStorage.Intermission status.Value = "Time until next round: " inter.Value = 30 repeat inter.Value -= 1 wait(1) until inter.Value == 0 local Josh = game.ReplicatedStorage.Spawn:Clone() Josh.Parent = workspace for i, plr in pairs(game.Players:GetPlayers()) do local Character = plr.Character if Character then Character.HumanoidRootPart.CFrame = Josh.CFrame plr.Humanoid.WalkSpeed = 0 end end status.Value = "" inter.Value = 3 wait(1) inter.Value = 2 wait(1) inter.Value = 1 wait(1) inter.Value = 0 status.Value = "Go!" wait(1) status.Value = "" Josh:Destroy() for i, plr in pairs(game.Players:GetPlayers()) do local Character = plr.Character if Character then plr.Humanoid.WalkSpeed = 16 end end end
You can use LocalPlayer unless you're in a local script. If this is a local script, change it right now because you are screwing up the code for other players by having multiple local scripts. If you want to do what you are doing, use a for loop that loops through the players characters that teleports them.
You are unable to recieve the "LocalPlayer" by doing game.Players.LocalPlayer on a ServerScript, as that runs on the server.
There are multiple ways of receiving the player, for example, you could use events with parameters that returns the player.
EXAMPLE
game.Players.PlayerAdded:Connect(function(plr) player = plr end)