How can I make it so that when you spawn your on the Alive team but when you die you swap to the Dead team. I also need it so that when everyone is dead the leaderboard resets so everyone is on the alive team once again.
COMMUNITY QUESTION
Alive and Dead leaderboard?
1 answer
This is what you would do, you'd need two teams, the Dead Team AutoAssignable property would be set to true, while the Survivors team AutoAssignable property would be set to false.
And this is how it would look like in a serverscript.
local Teams=Game:GetService("Teams")
local SurvivorsTeam=Teams:WaitForChild("Survivors")
local DeadTeam=Teams:WaitForChild("Dead")
local function ResetTeams()
local Players=Game.Players:GetPlayers()
for _,v in ipairs(Players) do
if v.TeamColor==BrickColor.new(DeadTeam.TeamColor.Name) then --Get All Players and set their TeamColor to "Survivors"
v.TeamColor=BrickColor.new(SurvivorsTeam.TeamColor.Name)
end end end
Game.Players.PlayerAdded:connect(function(player) --Player Joined
player.CharacterAdded:connect(function(character) --Player's Character Loaded
character:WaitForChild("Humanoid").Died:connect(function() --Player's Character died
if player.TeamColor==BrickColor.new(SurvivorsTeam.TeamColor.Name) then
player.TeamColor=BrickColor.new(DeadTeam.TeamColor.Name)
end end)end)end)
ResetTeams()
If you have any question just ask me!
This discussion is preserved as it was. New answers, comments, and votes are closed.
