|
| 28 Sep 2014 01:24 AM |
| Hey guys, so i am creating a tournament and i am having trouble scripting.Can someone please tell me how to check which players are alive during the round and which players have died |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 04:20 AM |
I would do it like this:
for i,v in ipairs(game.Players:GetChildren()) do local b = Instance.new("BoolValue", script) b.Name = v.Name b.Value = true v.Character.Humanoid.Died:connect(function() if script:findFirstChild(v.Name) then script:findFirstChild(v.Name).Value = false end end) end
--This makes a BoolValue for every player. If it's set to true, it means the player is alive, if it's false, the player died. If a new round starts, you should make it remove all the values again and insert new ones. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 04:50 AM |
Just make a player data object...
local PlayerData = {} PlayerData.new = function(name) local this = {} this.Name = name this.Dead = false this.Points = 0 return this end
local Players = {}
local removePlayer = function(plr) table.insert(Players, PlayerData.new(plr.Name) end
local addPlayer = function(plr) for _, v in pairs(Players:GetChildren()) do if(v.Name == plr.Name)then table.remove(Players, v) end end end
game.Players.PlayerRemoving:connect(function(player) removePlayer(player) end)
game.Players.PlayerAdded:connect(function(player) addPlayer(player) end)
|
|
|
| Report Abuse |
|
|