Unable to assign property CFrame. CoordinateFrame expected, got Instance

help me i don’t get this error.
Unable to assign property CFrame. CoordinateFrame expected, got Instance

function playerModule.teleportPlayer(playerName, teleportLocation)
	local gamePlayer = game.Players:FindFirstChild(playerName)
	if gamePlayer then
		local character = gamePlayer.Character or gamePlayer.CharacterAdded:Wait()
		character.HumanoidRootPart.CFrame = teleportLocation.CFrame
		events:WaitForChild("ToggleMainMenu"):FireClient(gamePlayer, false)
	end
end
1 Like

Could you provide what “teleportLocation” equals to?

1 Like

–Main Script

playerModule.teleportAllPlayers(workspace.Chapter1.Spawn)

–Module Script

function playerModule.teleportPlayer(playerName, teleportLocation)
	local gamePlayer = game.Players:FindFirstChild(playerName)
	if gamePlayer then
		local character = gamePlayer.Character or gamePlayer.CharacterAdded:Wait()
		character.HumanoidRootPart.CFrame = teleportLocation.CFrame
		events:WaitForChild("ToggleMainMenu"):FireClient(gamePlayer, false)
	end
end

function playerModule.teleportAllPlayers(teleportLocation)
	for index, player in pairs(roundInfo.Players:GetChildren()) do
		playerModule.teleportPlayer(player.Name, teleportLocation)
	end
end

I assume line 5 in the snippet is failing?
Try printing out gamePlayer.Name and teleportLocation.Name and see what that gives you

1 Like

AkexinxYedek, Spawn

(([[||character limit||]]))

Is there any child in either the spawn or the player named CFrame?

1 Like

no.

(charrrrrrrrrrrrrrracter limit)

Try:

function playerModule.teleportPlayer(playerName, teleportLocation)
	local gamePlayer = game.Players:FindFirstChild(playerName)
	if gamePlayer then
		local character = gamePlayer.Character or gamePlayer.CharacterAdded:Wait()
		character:SetPrimaryPartCFrame(teleportLocation.CFrame)
		events:WaitForChild("ToggleMainMenu"):FireClient(gamePlayer, false)
	end
end

function playerModule.teleportAllPlayers(teleportLocation)
	for index, player in pairs(roundInfo.Players:GetChildren()) do
		playerModule.teleportPlayer(player.Name, teleportLocation)
	end
end

3 Likes

Thanks! its worked. :smiley:
(char limit)

1 Like