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

Everytime this script runs, It makes me face a direction I wasn't facing when I used it. Help?

Asked by 8 years ago
Players = game.Players.LocalPlayer
mouse = Players:GetMouse()





mouse.KeyDown:connect(function(key)
if key == "t" then
    xPos = game.Players.LocalPlayer.Character.Torso.Position.X
    yPos = game.Players.LocalPlayer.Character.Torso.Position.Y
    zPos = game.Players.LocalPlayer.Character.Torso.Position.Z
    game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(Vector3.new(xPos,yPos + 50,zPos))

end
end)

So I made a script that teleports you up 50 studs but the problem is, when launched('t' is pressed), it takes you up, then makes you face a random direction. No matter what you're looking, when the script is launched, you still face that same,random direction. Any advice on how to fix?

0
If that's the case why don't you get the players torso Rotation XYZ before teleporting and store it in a variable then after you teleport just set the torso Rotation to that variable? Cuvette 246 — 8y
0
I already tried that...no luck there. secretboy6 68 — 8y

1 answer

Log in to vote
2
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

Use :TranslateBy()

It will move the model using the given vector3 value.

player = game.Players.LocalPlayer
mouse = Players:GetMouse()

game:GetService("UserInputService").InputBegan:connect(function(key) --KeyDown is depreciated
    if key.KeyCode == Enum.KeyCode.T then --tttttttttt
        player.Character:TranslateBy(Vector3.new(0,50,0))
    end
end)


0
Oh thanks. I've never heard of that method... secretboy6 68 — 8y
0
happy to help theCJarmy7 1293 — 8y
Ad

Answer this question