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

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

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?

2 comments

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?

0

I already tried that...no luck there.

1 answer

✓ Accepted answer

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)


2 comments

0

Oh thanks. I've never heard of that method...

0

happy to help

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