Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Alive and Dead leaderboard?

Asked by 10 years ago

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.

1 answer

Log in to vote
0
Answered by
Nymint 85
10 years ago

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!

Ad

Answer this question