generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: help with minigame script

Previous Thread :: Next Thread 
025110 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
19 Mar 2015 05:58 PM
45k posts, and you still don't know when to tell us your error.
Report Abuse
025110 is not online. 025110
Joined: 23 Nov 2012
Total Posts: 57661
19 Mar 2015 05:59 PM
"--here "

no error, just need help
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
19 Mar 2015 06:00 PM
p.CharacterAdded:connect(function(Char)
Char:WaitForChild("Humanoid").Died:connect(function()
--
end)
end)
Report Abuse
025110 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
19 Mar 2015 06:02 PM
if players.a ~= nil then
end
Report Abuse
025110 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image