so theres a value in the player
so basically i want to play a function if EVERYONE's value is false. everyone together, not client sided.
i know you have to use the i, v in pairs loop thing but how do i check if EVERYONE's value is false??
so theres a value in the player
so basically i want to play a function if EVERYONE's value is false. everyone together, not client sided.
i know you have to use the i, v in pairs loop thing but how do i check if EVERYONE's value is false??
Use this, this should work since what it does is go through every current player in the server and check if the value is false, this is not client sided this is a server sided script.
for _,v in pairs(game.Players:GetPlayers()) do
if v.Value == false then
--function
end
end
It wouldn't work, as the script above will go through all the players 1by1, if the players value is false, it will fire the function, it would fire once for every false player.
you cant be certain, it will work on some/most occasions, if this doesnt work then he'd have to provide further info so we can actually help him.
I guess it kind of works... Thanks!
Yeah, I am sure it will work, just not perfectly, and I think you will be able to work with it and make the solution you want yourself.
Hope this work:
function checkPlayer()
for i, v in pairs (game.Players:GetPlayers()) do --loop through all players
if not v.BoolValue.Value then --check is the value inside the player is false or not
return false -- if it false then return false
end
end
return true -- if every player's value is true then return true
end
-- the rest of the code goes here
Yeah, thanks for answering this so I wouldn't have to lol. Great thinking.
You can use if-then statement to check is the function that i provide, if it true then run your function.
guys im dumb i dont know why he accepted my answer lol, he should accept yours XD.
Maybe my answer is kinda hard to understand for him but meh
It was probably because he somehow got the previous answer to work and didn't look at your answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.
6 comments
The normal in pairs loop wouldn't work, as it would check if any of the players value is false and then fire that many times. It would have to be something that either counts the falses or cancels the function when it finds a player whos value is true.
@Torren_Mr no, i think it really depends on what he wants to use it for, if he only wants to check then the normal in pairs loop will work.
and he can still use the normal in pairs loop for multiple other scenarios.
Not really, he made it pretty clear he only wants to play the function if EVERYONE's value is false, so the normal in pairs loop would play it when one players value is false too. I have some ideas but I am currently unable to write a code.
hmm... yeah, you're right lol, never thought about that.
i thought he wanted to do a function on the player if the players value is false.