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

How do you change teams when you die? [closed]

Asked by 10 years ago

You know how in games like R2D when your team is changed to green when you die? How do you switch teams when you die? This is my script, Ill point out the part I need help with. The part that is broken is bold

playteam = game.Teams["Survivors"] spectators = game.Teams["Dead"] -- Variables

while true do wait() end local msg = Instance.new("Hint") msg.Parent = nil msg.Parent = game.Workspace local randmap = math.random(1,1) local plr = game.Players:GetPlayers() for i = 1, #plr do if plr[i].Character.Humanoid.Health < 1 then plr[i].TeamColor = spectators.TeamColor end if randmap == 1 then msg.Parent = game.Workspace msg.Text = "Picking Random Map" wait(3) msg.Text = "Map chosen: Baseplate" wait(3) msg.Text = "OBJ: Build your own structures to withstand the flood." wait(5) msg:remove() plr[i].TeamColor = playteam.TeamColor plr[i].Character:FindFirstChild("Humanoid").Health = 0 game.Lighting.Copy:clone().Parent = game.StarterPack game.Lighting.PaintBucket:clone().Parent = game.StarterPack game.Lighting["Dragger"]:clone().Parent = game.StarterPack game.Lighting.Delete:clone().Parent = game.StarterPack copy = game.ServerStorage.Map1:clone() copy.Parent = game.Workspace wait(15) local FloodWater = game.Workspace.Map1:FindFirstChild("FloodWater") FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) FloodWater.CFrame = FloodWater.CFrame + Vector3.new(0,1,0) wait(.5) wait(10) msg.Parent = game.Workspace msg.Text = "The winners will be awarded 10 points!" msg:remove() game.Workspace.Map1:remove() plr[i].TeamColor = spectators.TeamColor end end end

Closed as Not Constructive by xImmortalChaos, EzraNehemiah_TF2, and adark

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 10 years ago

Not sure what any of that had to do with the real question. But for one you should check out the wiki.Roblox.com/ which can list most answers for lua errors or problems, or any other sources before coming here. But the answer to your question is so:

game.Players.PlayerAdded:connect(function(Player) --Just a way for me to get the Player.
Player.CharacterAdded:connect(function(Character) --Just a way for me to get the Player's Character.
repeat wait() until Character:FindFirstChild("Humanoid") ~= nil --Wait's for the Player's humanoid. The basis to a Character's health.
Character.Humanoid.Died:connect(function() --Called when a Player dies.
if Player.TeamColor == game.Teams.Survivors.TeamColor then --Checks to see if the Player was alive, or in other words playing in the 'game round'.
Player.TeamColor = game.Teams.Dead.TeamColor --Changes the player's team, on death.
end
end)
end)
end)
Ad