Four team colors/spawns respawning to one color/spawn

Hi,
This game has four team colors Red, Blue, Green, and Yellow. When the players initially login they are appropriately assigned to a team and its matching color spawn. The game is cycled with a round timer. When the timer reaches 0 then the players are CFramed back to the spawn points. However, when the round is up (timer zero) all of the players are respawned to the red spawn point (which happens to be the 1st of 4 spawns I added to studio) even though I can see the players are all still assigned to their original team color in the player properties.

In this script the player is respawned when a boolval is changed to false. I cannot figure out how to call out the original SpawnLocation color that the player logged into originally. So that when the boolval “inRound” is false the player is transported back to their original team SpawnLocation instead of the red one. I think that since I’m not killing the players is why Studio doesn’t know to spawn them back but I’m not sure that’s an efficient way to handle this?

inRound.Changed:Connect(function()
	if inRound.Value == false then
		for i, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame
		end
	end
end)

Thanks,
D

2 Likes

What’s the GameAreaSpawn variable?

This text will be blurred

1 Like

What you can do is

image

Name the SpawnLocations according to the teams. So now they’re easy to refer to and identify.

Now when you teleport them to their spawnlocation, you can now access their respective spawnlocation using the name of their team

So i.e


char.HumanoidRootPart.CFrame = workspace[player.Team.Name].CFrame

1 Like

Thanks,

local GameAreaSpawn = game.Workspace.SpawnLocation

Looks like I don’t need this callout though

1 Like

Thanks to both responders, that was it. Removed the local callout for SpawnLocation then updated the CFrame for [player.Team.Name] instead of that SpawnLocation. Updated the SpawnNames for consistency.

inRound.Changed:Connect(function()
	if inRound.Value == false then
		for i, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = workspace[player.Team.Name].CFrame
		end
	end
end)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.