How to get original CFrame?

Hello, I made this script below which teleports players to different parts around a map to allow players to load the map quicker in all places. If I wanted to make the player go back to the original position they were in before typing the command, how would I go about doing this?

-- Load Map Command
game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(chat)
		if chat == ":loadmap" and Player:GetRankInGroup(GroupID)>= AllowedRank then
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP1.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP2.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP3.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP4.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP5.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP6.Position)
		end
	end)
end)

can you hold the players’ current CFrame before you begin reassigning it? like:

local oldCFrame = Player.Character.HumanoidRootPart.CFrame
--finish teleporting around...
wait(1.5)
Player.Character.HumanoidRootPart.CFrame = oldCFrame
1 Like

before tping the player just make a variable called OLDCF and set it to the platers CFrame or just copy this code

local OLDCF = Player.Character.HumanoidRootPart.CFrame

the finished code would look like this

-- Load Map Command
game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(chat)
		if chat == ":loadmap" and Player:GetRankInGroup(GroupID)>= AllowedRank then
			local OLDCF = Player.Character.HumanoidRootPart.CFrame
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP1.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP2.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP3.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP4.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP5.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts.TP6.Position)
			wait(1.5)
			Player.Character.HumanoidRootPart.CFrame = OLDCF
		end
	end)
end)
1 Like