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 my function?

Previous Thread :: Next Thread 
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:07 PM
function checkplayers()
for _,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then
playersdead = false
elseif v:FindFirstChild("InGameTag") then
playersdead = true
end
end
end


Instead of checking just one player how would I check all players as a whole? As in, I want to see if all players fit these standards.
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
30 May 2015 11:08 PM
for i,v in pairs (game.Players:GetChildren()) do
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:09 PM
do i replace the v with i?
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:10 PM
that didnt help
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
30 May 2015 11:11 PM
It seems like you already are looking through all the players?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 May 2015 11:11 PM
function checkplayers()
for i,v in pairs(game.Players:GetChildren()) do
if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then
playersdead = false
elseif v:FindFirstChild("InGameTag") then
playersdead = true
end
end
end
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:12 PM
No i mean, whenever just 1 player fits the standard for "dead", it says that all players are dead
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
30 May 2015 11:14 PM
function checkplayers()
for _,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("AliveTag") and v:FindFirstChild("InGameTag") then
return false
end
end
return true
end

To return false if any of the players are still alive.
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:16 PM
That just instantly put playersdead = true
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
30 May 2015 11:18 PM
Replace the returns with playersdead =
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:19 PM
I did, see my problem is when a new player joins, it somehow decides that they are representing that all players are dead.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 May 2015 11:20 PM
I have an easier workaround to this.

Just create a boolvalue inside the player when they join that changes to false if they die, then check all the boolvalues in the players. if a boolvalue is true, then those players are alive.
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
30 May 2015 11:23 PM
I'll see what I can do with this. Be back in a bit.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
30 May 2015 11:38 PM
Its easy. I set up everything for you.
----------------------------------------------------------

function onDied(human, player)
local playing = player:FindFirstChild("IsPlaying")
if not playing then
return
else
if player.IsPlaying.Value == true then
player.IsPlaying.Value = false
end
end
end

function onRespawn(property, player)
if property == "Character" and player.Character then
local human = player.Character:FindFirstChild("Humanoid")
local p = player
local h = human
human.Died:connect(function() onDied(h, p) end)
end
end

game.Players.ChildAdded:connect(function(player)
local IsPlaying = Instance.new("BoolValue")
IsPlaying.Name = "IsPlaying"
IsPlaying.Value = true
IsPlaying.Parent = player

while true do
if player.Character then
break
end
wait(5)
end

local human = player.Character:FindFirstChild("Humanoid")
human.Died:connect(function() onDied(human, player) end)
player.Changed:connect(function(property) onRespawn(property, player) end)

IsPlaying.Parent = player
end)

----------------------------------------------------------------------------
Then in a separate script after the game is finished just do this

for i,v in pairs(game.Players:GetChildren()) do
if v:FindFirstChild("IsPlying") then
v.IsPlaying.Value = true
end
end
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
30 May 2015 11:40 PM
Use :GetPlayers not :GetChildren
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
31 May 2015 04:57 PM
So how do I use that within this:

timer.Value = 45
for i = 45, 0, -1 do
wait(1)
timer.Value = timer.Value - 1
status.Value = timer.Value
-- HERE "then break end"
if won.Value then break end
end -- i = end thing



How would I check if all the players are "dead" collectively with that being used. Cause if I used for i,v in pairs and used if v.BLAHBLAH it would only show for that player




Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
31 May 2015 05:17 PM
b
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