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

How do I make limited team respawns?

Im making a little game for me and my friends and I need help making a specific team only have 3 respawns. Couldnt find anything in the api reference and I dont have the gamer knowledge to figure out it without the reference.

1 answer

You can use a script that keeps track of everytime a person respawns and changes a variable based on that, then once that variable reaches 3 you do something to prevent them from respawning. Ex. move all players on that team to another team that has a spawn which is inside of an invisible box floating in the sky where they can watch the other team celebrate their victory.

To accomplish this you could do something like this

local Team1Respawns = 0
local Team2Respawns = 0
local MaxRespawns = 3

game.Players.PlayerAdded:Connect(function(Player)
	local HasPlayerSpawnedBefore = false
	Player.CharacterAdded:Connect(function()
		if HasPlayerSpawnedBefore == false then
			HasPlayerSpawnedBefore = true
		else
			if Player.Team == "NameOfTeam1" then
				Team1Respawns = Team1Respawns + 1
				if Team1Respawns  > MaxRespawns then
					Player.Team = SpectatorTeam
					Player.Character.Humanoid.Health = 0 --kills them so that they respawn at the spectator team's spawn
				end
			elseif Player.Team == "NameOfTeam2" then
				Team2Respawns = Team2Respawns + 1
				if Team2Respawns  > MaxRespawns then
					Player.Team = SpectatorTeam
					Player.Character.Humanoid.Health = 0 --kills them so that they respawn at the spectator team's spawn
				end
			end
		end
	end)
end)

5 comments

0

hmm ill see if i am capable of doing this

1

i updated the answer to try and help you more

0

Sorry for the somewhat late reply but thank you. Ill see if this works

0

Where would i put the script? just in the workspace or like a service?

1

I would put it in the ServerScriptService

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