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

so how do I make all the players not spawn at one spawn point?

so i make my players sit in the waiting room and then they get tp to the arena. My arena has 5 spawn areas but when ever the players a sent, they spawn in one area. Please help me.


local roundlength = 5
local intermissionLength = 10
local InRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status


local Lobby = game.Workspace.Lobby.SpawnLocation
local Arena = game.Workspace.Arena.SpawnLocation

InRound.Changed:Connect(function()
	wait(1)
	if InRound.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = Arena.CFrame
			
		end
	else
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = Lobby.CFrame
			end
	end
end)
local function roundTimer()
	while wait() do 
		for i = intermissionLength, 1, -1 do
			InRound.Value = false
		
			wait(1)
			status.Value = "Intermission: ".. i .." seconds left BOOMER!"
			
		end
		for i = roundlength, 1, -1 do
			InRound.Value = true
			wait(1)
			status.Value = "YOU HAVE ".. i .." SECONDS LEFT UNTIL WE HAVE A WINNER NERD!!"
		end
	end
end
spawn(roundTimer)

2 comments

0

Hello, are the players spawning using a SpawnLocation or a teleport?

0

they are using a spawnlocation

1 answer

✓ Accepted answer

The problem is that you are teleporting each player to a precise CFrame (see lines 15 and 21). You have these options:

  • Get a list of all spawn locations you want them to spawn at and teleport each player to a random one (or set player.RespawnLocation to a random one and then call player:LoadCharacter() to respawn them)
  • Disable all spawn locations that you don't want them to spawn at and call player:LoadCharacter()

[Edit in response to comment]

That doesn't exist; consider using https://developer.roblox.com/en-us/api-reference/datatype/Random or simply math.random().

You'll also need to get a list of SpawnLocations. If you create a folder with nothing but the SpawnLocations, you can use :GetChildren() to get just them.

However you do it, you can select a random element from list using list[math.random(1, #list)] or using that Random type I linked).

4 comments

0

so do i do spawnlocation.random?

0

Edited

0

im not that good at coding so could you give me an example of what you mean?

0

I recommend looking up tutorials on YouTube or online. Experiment with things, "print()" values and expressions, use for loops, etc - once you get the hang of more of it, what I said shouldn't be as hard to figure out.

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