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())

1 comment

0

Are the spawns a part? If not, then you might not be able to get CFrame that way.