Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

when they teleport they land on top of each other. how do i offset it?

wait(2) --teleport
function teleAll(x, y, z)
    local pos = Vector3.new(x, y, z)
    for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
        if plr.Character then
            plr.Character:MoveTo(pos)
        end
    end
end

teleAll(0, 2, 0)

how do I add an offset so they spawn in random positions around the board information that may or may not be useful the script is in serverscript position of board -19.172, 83.968, -5.537 the board is a union

2 comments

0

Roblox SpawnLocation's spread players out over the size of the SpawnLocation when they spawn in now. The easiest fix would be to put a SpawnLocation where you want people to teleport to and scale it's x and z axis out until it's big enough to comfortably fit all of your players. Then in your teleport function, set the players RespawnLocation and call LoadCharacter. Would this work for you?

0

yeah it would how do you do that

1 answer

✓ Accepted answer

Place a SpawnLocation where you want the players to be appearing. Scale it up so that there is plenty of room for the players to all spawn in without appearing on top of each other. You can set the SpawnLocation to transparent if you like. You also need it to be set to neutral or to the players team color. Then you can just use the script you have, but change it slightly to set the players RespawnLocation and call LoadCharacter.

wait(2) --teleport
function teleAll()
	for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
		plr.RespawnLocation = workspace.YourSpawn
		plr:LoadCharacter()
	end
end

teleAll()

Change workspace.YourSpawn to the name of the SpawnLocation that you created. Just be aware that the players will keep spawning in that location if they die unless you set another spawn location for them.

3 comments

0

it says Error bad cast

0

for teleAll()

0

You will get that error if workspace.YourSpawn isn't a SpawnLocation. Double check that you are setting it to the SpawnLocation that you added

This discussion is preserved as it was. New answers, comments, and votes are closed.