for some reason, the players wont teleport to the mini game area. I have no clue why it doesn't work now as it used to work before. Can someone see where it is wrong - no errors are shown.

Local AllPlayers = game.Player:GetChildren()

function TeleportPlayerToMap()
    for i = 1,#AllPlayers do
        if AllPlayers[i]:WaitForChild("Settings").AFK.Value ~= true then
            if AllPlayers[i] ~= nil then
                if AllPlayers[i].Character ~= nil then
                    if AllPlayers[i].Character:FindFirstChild("Humanoid").Health ~= 0 then
                        local spawns = CurrentMap:FindFirstChild(MapSelected.Value):FindFirstChild("Spawns"):GetChildren()
                        if spawns ~= nil then
                            local ransp = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,3,0)
                            AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                            wait()
                            if AllPlayers[i] ~= nil then
                                if AllPlayers[i].Character ~= nil then
                                    AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                                end
                            end
                            wait()
                            if AllPlayers[i] ~= nil then
                                if AllPlayers[i].Character ~= nil then
                                    AllPlayers[i].Character.HumanoidRootPart.CFrame = ransp
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

2 comments

0

other variables not defined in this segment are defined elsewhere

0

I don't have enough time to look at the whole script, but I see the wrong variable at the first line. You used "game.Player" while you should use "game.Players".