Is it possible to have a separate spawn locations for each player?

Hello. This is my first post, so be gentle :slight_smile:

I am working on a game that introduces a lot of new concepts, and has been a bit confusing for my friends who have tried it. Therefore I have added a tutorial. Unfortunately, for the tutorial to work properly, each player must spawn at dedicated single player area, and work their way to the main arena. I want new players to spawn at these places, with the option to skip tutorial.
I have made 16 tutorial teams, and 16 corresponding spawns. I also wrote a script that should sort players to those teams.

local TUTORIAL_COLORS = {
"Earth green",
"Slime green",
"Bright bluish green",
"Black",
"Deep blue",
"Dark blue",
"Navy blue",
"Parsley green",
"Dark green",
"Teal",
"Smoky grey",
"Steel blue",
"Storm blue",
"Lapis",
"Dark indigo",
"Camo",

}
local tutorialAssignment = {}

local function onPlayerAdded(player)

player.CharacterAdded:Connect(onCharacterAdded)
player.CharacterRemoving:Connect(onCharacterRemoving)

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
	
local level = Instance.new("StringValue")
level.Name = "Level"
level.Value = 1
level.Parent = leaderstats

local alignment = Instance.new("StringValue")
alignment.Name = "Alignment"
alignment.Value = "Neutral"
alignment.Parent = leaderstats

local wins = Instance.new("StringValue")
wins.Name = "Wins"
wins.Value = 0
wins.Parent = leaderstats

local pick = math.random(16)
repeat
	wait()
	local random = math.random(16)
until tutorialAssignment[pick] == nil
print(player.Name .. " is " .. pick)
tutorialAssignment[pick] = player
player.TeamColor = BrickColor.new(TUTORIAL_COLORS[pick])

end
Players.PlayerAdded:Connect(onPlayerAdded)

Players.PlayerRemoving:Connect(function(player)
for index , value in pairs(tutorialAssignment) do
	if value == player then
		tutorialAssignment[index] = nil
	end
end

end)

However it does not work in studio Sometimes 2 players get different team, but they spawn at the same place. Sometimes they just remain on neutral team, and spawn randomly, even though there are no neutral spawns. Is it something to do with the studio (If so how do I test it, without 15 volunteers?), or spawn locations are not reliable, and I should code my own spawn system?

2 Likes

A more reliable way to set the spawn of a player is too use Player.RespawnLocation and set it to a SpawnObject. This will guarantee that the player will spawn there, and teams dont have to be used.

As for testing with 15 players, dont. Try it with 2 spawns and see if it works. The same principles apply to 15 players.

If you have any more questions or concerns, feel free to ask them.

9 Likes

Like @REALTimothy0812 said, don’t. But if you need to test with a couple of players players at some point, read up on game testing. You can simulate lots of different clients to check if you systems work.

1 Like