Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would i use i, v in pairs loops with this???

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

6 comments

0

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.

0

@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.

0

and he can still use the normal in pairs loop for multiple other scenarios.

0

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.

0

hmm... yeah, you're right lol, never thought about that.

0

i thought he wanted to do a function on the player if the players value is false.

2 answers

✓ Accepted answer

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	
	

4 comments

0

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.

0

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.

0

I guess it kind of works... Thanks!

0

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

5 comments

0

Yeah, thanks for answering this so I wouldn't have to lol. Great thinking.

0

You can use if-then statement to check is the function that i provide, if it true then run your function.

0

guys im dumb i dont know why he accepted my answer lol, he should accept yours XD.

0

Maybe my answer is kinda hard to understand for him but meh

0

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.