01 | -- Takes every player, except AFK players and put them on the maps spawn points |
02 | for i = 1 , #Players do |
03 | if Players [ i ] :WaitForChild( "Backpack" ):WaitForChild( "AFK" ) = = false then |
04 | local GetSpawns = PMCopy.Spawns:GetChildren() |
05 | local Spawns = GetSpawns [ math.random( 1 , #GetSpawns) ] |
06 | local Char = game.Workspace:FindFirstChild(Players [ i ] .Name) |
07 | Players [ i ] :WaitForChild( "Backpack" ):WaitForChild( "Playing" ).Value = true |
08 | Char:MoveTo(Spawns.Position) |
09 | end |
10 | end |
For some reason, the if statement is not working... no errors show up. Please help!
Instance:WaitForChild(name) returns an object.
Learn more about WaitForChild on the Roblox Developer Wiki.
01 | -- Takes every player, except AFK players and put them on the maps spawn points |
02 | for i = 1 , #Players do |
03 | if not Players [ i ] :WaitForChild( "Backpack" ):WaitForChild( "AFK" ) then |
04 | local GetSpawns = PMCopy.Spawns:GetChildren() |
05 | local Spawns = GetSpawns [ math.random( 1 , #GetSpawns) ] |
06 | local Char = game.Workspace:FindFirstChild(Players [ i ] .Name) |
07 | Players [ i ] :WaitForChild( "Backpack" ):WaitForChild( "Playing" ).Value = true |
08 | Char:MoveTo(Spawns.Position) |
09 | end |
10 | end |
Actually I forgot to put .Value so... It's fixed! No problems