Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
KingDomas 153
4 years ago

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.

0
their HumanoidRootPart's CFrame, not the player itself DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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
0
Thanks. KingDomas 153 — 4y
Ad

Answer this question