Error when teleporting player

Hey, I’m trying to teleport all players into a map that’s randomly chosen from Replicated Storage. However, I am getting an error which reads:

"Unable to assign property CFrame. CoordinateFrame expected, got nil"

This is the script I have wrote for the Teleport Section of it:

--// Intermission

for i = 20, 0, -1 do --// 20 = Intermission Length
	Status.Value = "Intermission in: "..i
	task.wait(1)
end

local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
local SpawnLocations = ChosenMap:FindFirstChild("TeleportPoint"):GetChildren()

ChosenMap.Parent = game.Workspace
Status.Value = "Map Chosen: "..ChosenMap.Name

task.wait(5)
print("Teleporting to Map")

--// Telporting

for i, Player in pairs(game.Players:GetPlayers()) do
	local character = Player.Character
	if character then
		local HRP = character.HumanoidRootPart
		HRP.CFrame = SpawnLocations.CFrame
	end
end

Change SpawnLocations.CFrame to SpawnLocations[math.random(1,#SpawnLocations)].CFrame

It now throws an error of:

ServerScriptService.Rounds:31: invalid argument #2 to ‘random’ (interval is empty)

How many spawn locations are there?
Are there even parts inside TeleportPoint?

Nevermind! I made a mistake with the spelling of the spawns. Thank you.

1 Like