Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you grab a LocalPlayer's CFrame position, and then teleport elsewhere?

The title says it all.

I've never been good with moving things with scripts, and I don't know how to grab a player's CFrame. Any help would be appreciated!

Basically what I want to do, is grab the LocalPlayer's CFrame after a certain function is ran, and then it teleports them to somewhere else and back after waiting a few seconds.

1 comment

0

their HumanoidRootPart's CFrame, not the player itself

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer
function teleport(pos, t)
	local oldCFrame = player.Character:GetPrimaryPartCFrame() --Grabs prev. player CFrame
	player.Character:SetPrimaryPartCFrame(pos) --Teleports player to new CFrame
	wait(t) --Waits specified amount of time
	player.Character:SetPrimaryPartCFrame(oldCFrame) --Teleports player back to oldCFrame
end

teleport(CFrame.new(0, 100, 0), 1) --Example call that teleports player to 0, 100, 0 and back after 1 second

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.