How can I make a script that looks through every player's Character and if the script finds a Bool Value inside the player's Character Model then they get teleported to a destination and if the script doesn't find any Bool Value in everyone else, then the ones that didn't have a Bool Value get teleported to a different destination.
✓ ANSWER ACCEPTED
How can I make a script that separates everyone that don't have a Bool Value?
1 answer
✓ Accepted answer
Ok, I am a bit rusty with this kind of stuff but you basically need to loop through every player and retrieve their character from the player and see if there is a bool value inside. After that just set the primary part cframe and it should work :D
for i,player in pairs(game.Players:GetPlayers()) do
print("player")
local character = player.Character
if character then
print("character")
local playerbool = character:FindFirstChild("PlayerBoolValue")
if playerbool then
if playerbool.ClassName == "BoolValue" then
print("boolfound")
character:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,0,0)))
-- Vector3.new(0,0,0) should be the position you want the character to be or a part.Position
end
end
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Btw, put the code in a script in the workspace if you want and see what will happen if you put wait(15) at the top of the code.
I got an error when the script got to the for loop, Workspace.GameController:50: attempt to call a nil value
Turns out I just had to remove :GetPlayers() and it worked, thanks for the help!
Yay :D
Using ClassName is bad practice, use IsA() instead as it supports inheritance. Also, isn't any object called PlayerBoolValue going to be a bool value? You don't really need to check.