So this script teleport all players to the certain position that I put. But then when all players teleport, they all teleport on top of each other and glitch to the top of the roof which I don't like. So how do I make this:
target = Vector3.new(-52.8, 10.5, 9.4) -- The positon I want them to teleport. for i, v in pairs(game.Players:GetChildren()) do v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0)) end
Spawn to SpawnLocation or not spawn on top of each other?
local target = CFrame.new(-52.8, 10.5, 9.4) for _,plr in next, game.Players:GetPlayers() do --Always use next, ... It's easier in my opinion. Also always always always use game.Players:GetPlayers(). It's more efficient. plr.Character.Torso.CFrame = target end
Should help you out.
Use the PlayerAdded and CharacterAdded event. The Character Added event will call when a player and the player's character has spawned.
It's like a Touched event. It is an event for the Players service. So we can do this:
game:GetService("Players").PlayersAdded:connect(function(player) --see the "player"? This is the player print(player.Name) --Prints the player's name. end)
This will check if a player's character has spawned. The easiest way to get the player is through player added.
game:GetService("Players").PlayersAdded:connect(function(player) player.CharacterAdded:connect(function(character) --the "character" is the character. character.Humanoid.Health = 0 --This is like a loop kill... end) end)
local target = CFrame.new(-52.8, 10.5, 9.4) game:GetService("Players").PlayersAdded:connect(function(player) player.CharacterAdded:connect(function(character) character.Torso.CFrame = target end) end)
Hope this helps! This is for a spawn script. If you want something else please msg me. I can make any script for you.