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

If statement not working with no errors even?

-- Takes every player, except AFK players and put them on the maps spawn points
	for i = 1, #Players do
		if Players[i]:WaitForChild("Backpack"):WaitForChild("AFK") == false then
			local GetSpawns = PMCopy.Spawns:GetChildren()
			local Spawns = GetSpawns[math.random(1, #GetSpawns)]
			local Char = game.Workspace:FindFirstChild(Players[i].Name)
			Players[i]:WaitForChild("Backpack"):WaitForChild("Playing").Value = true
			Char:MoveTo(Spawns.Position)
		end
	end

For some reason, the if statement is not working... no errors show up. Please help!

2 answers

Instance:WaitForChild(name) returns an object.

Learn more about WaitForChild on the Roblox Developer Wiki.

-- Takes every player, except AFK players and put them on the maps spawn points
    for i = 1, #Players do
        if not Players[i]:WaitForChild("Backpack"):WaitForChild("AFK") then
            local GetSpawns = PMCopy.Spawns:GetChildren()
            local Spawns = GetSpawns[math.random(1, #GetSpawns)]
            local Char = game.Workspace:FindFirstChild(Players[i].Name)
            Players[i]:WaitForChild("Backpack"):WaitForChild("Playing").Value = true
            Char:MoveTo(Spawns.Position)
        end
    end

Actually I forgot to put .Value so... It's fixed! No problems

This discussion is preserved as it was. New answers, comments, and votes are closed.