Teleport function not working

Hello everyone :slight_smile:

I recently bought a story game kit from the library, but the teleport function, which needs to teleport players to a specific part in Workspace, isn’t working. Am I doing something wrong, or is the script not correct?

The function:

function teleportPlayers(partCFrame)
	local players = game.Players:getPlayers()
	for _,player in pairs(players) do
		if player.Character then
			if player.Character.HumanoidRootPart.Anchored == false then
				player.Character.Humanoid.Jump = true
			end
		end
	end
	wait(.5)
	for _,player in pairs(players) do
		if player.Character then
			if player.Character.HumanoidRootPart.Anchored == false then
				player.Character:SetPrimaryPartCFrame(partCFrame)
			end
		end
	end
end

When the script needs to teleport players:

teleportPlayers(game.Workspace.TeleportPart.Position)

You’re sending a Position not a CFrame, have you tried sending the CFrame instead? TeleportPart.CFrame

1 Like

instead of

teleportPlayers(game.Workspace.TeleportPart.Position)

try using this instead

teleportPlayers(game.Workspace.TeleportPart.CFrame)

Try using PivotTo() here instead.

player.Character:PivotTo(partCFrame)