Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My Loop Doesn't Loop Through Players?

Asked by 4 years ago

Recently, I was trying to loop through the players to teleport them, but somehow, the loop doesn't work.

I made sure that the function called by printing "Called"

local players = game.Players:GetPlayers()

local function teleportToMap(Spwans)
    print("Called")

    for i,plr in pairs(players) do
        if plr.Character then
            if plr.Character:FindFirstChild("HumanoidRootPart") then
                plr.Character.HumanoidRootPart.CFrame = Spwans[math.random(1,#Spwans)].CFrame

            end
        end
    end
end

teleportToMap(workspace.Map:WaitForChild("Spawns"):GetChildren())
0
Are the spawns a part? If not, then you might not be able to get CFrame that way. Dovydas1118 1495 — 4y

Answer this question