025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 05:56 PM |
local players = { } for _,player in pairs(game.Players:GetChildren()) do if player:FindFirstChild("IsPlaying").Value then if player.Character:FindFirstChild("Humanoid").Health > 0 then player.Character.Humanoid:MoveTo(workspace.Start.Position) table.insert(players, player.Name:lower()) end end end
game.Players.PlayerAdded:connect(function(player) bool = Instance.new("BoolValue", player) bool.Value = true bool.Name = "IsPlaying" end)
game.Players:PlayerAdded:connect(function(p) p:WaitForChild('Character'):WaitForChild('Humanoid').Died:connect(function() --here --[[ check if they're in the tableif they are remove them]] end) end)
|
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 05:58 PM |
| 45k posts, and you still don't know when to tell us your error. |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 05:59 PM |
"--here "
no error, just need help |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:00 PM |
p.CharacterAdded:connect(function(Char) Char:WaitForChild("Humanoid").Died:connect(function() -- end) end) |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 06:01 PM |
I need help finding a value in a table
for instance
local players = { "e", "a", "o" }
how do I find if a is in that table? |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:02 PM |
if players.a ~= nil then end |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 06:03 PM |
so back to original script
========================
local players = { } for _,player in pairs(game.Players:GetChildren()) do if player:FindFirstChild("IsPlaying").Value then if player.Character:FindFirstChild("Humanoid").Health > 0 then player.Character.Humanoid:MoveTo(workspace.Start.Position) table.insert(players, player.Name:lower()) end end end
game.Players.PlayerAdded:connect(function(player) bool = Instance.new("BoolValue", player) bool.Value = true bool.Name = "IsPlaying" end)
p.CharacterAdded:connect(function(Char) Char:WaitForChild("Humanoid").Died:connect(function(human) if players.human.Name:lower() ~= nil then table.remove(players, human.Name:lower()) end end) end)
|
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:05 PM |
Oh wait, nope.. I did it wrong.
for _,a in pairs(players) do if a == "a" then print("Found") end end |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:05 PM |
Use isPlaying with a Dictionary.
players = { ["Player1"]=true, ["Player2"]=false, }
It makes your code much cleaner. |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 06:06 PM |
so
p.CharacterAdded:connect(function(Char) Char:WaitForChild("Humanoid").Died:connect(function(human)
for _,a in pairs(players) do if a == human.Name:lower() then table.remove(players, human.Name:lower()) end end end) end)
|
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:08 PM |
Nope.
If you want to remove a player, do this:
for i,a in pairs(players) do if a == human.Name:lower() then table.remove(players, i) end end |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 19 Mar 2015 06:09 PM |
do u mean (players, a)
or is it (players, i) |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2015 06:10 PM |
players, i
table.remove requires the position in the table, as opposed to the object in the table. |
|
|
| Report Abuse |
|
|