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

Why does this teleport script turn you upside down? [SOLVED]

I wrote this teleport script the other day and I just can not work out why it turns you upside down when you teleport or how to rectify it. Here is the script:

char = game.Players.LocalPlayer.Character
destination = game.Workspace.Bridged
 
function teleporter()
char.Torso.Anchored = true
char.Torso.CFrame = destination.CFrame + Vector3.new(0,0,0)
wait(0.2)
char.Torso.Anchored = false
end

script.Parent.MouseButton1Click:connect(teleporter)

Help would be much appreciated.

2 answers

✓ Accepted answer

It looks to me that destination is your issue. Since you're using its CFrame (as opposed to its Position) as the teleportation 'goal', the rotation of destination determines the rotation of the Torso after the teleportation.

There's a very simple way to get around this:

char = game.Players.LocalPlayer.Character
destination = game.Workspace.Bridged

function teleporter()
char.Torso.Anchored = true
char.Torso.CFrame = CFrame.new(destination.Position) + Vector3.new(0,0,0)
wait(0.2)
char.Torso.Anchored = false
end

script.Parent.MouseButton1Click:connect(teleporter)

CFrame.new(destination.Position) is, effectively, destination.CFrame, but with a Rotation of (0, 0, 0).

1 comment

0

Thanks a lot!

I would suggest using :MoveTo() on the character, instead of actually changing the torso's position.

:MoveTo() will move your character around, basically teleporting.

Let me give you an example:

Destination = game.Workspace.DestinationBrick

game.Workspace.TeleportingBrick.Touched:connect(function(hit)
local Detector = hit.Parent:FindFirstChild("Torso")
if Detector then

hit.Parent:MoveTo(Destination.Position) -- It's a shorter, and easier method.
end)

Hope this helped! Please upvote if it did.

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