In my code i have a mouse hit teleport that saves the CFrames rotation in Euler angles before the teleport then restores it using CFrame.Angles after
However instead of having the desired effect of rotating the player correctly where it was before, it moves the player back to the center of the world, sometimes pushing it through the floor
Can someone please go over my code and tell me what I'm using wrong?
Wait(1) local Player = game.Players.LocalPlayer local Cam = workspace.CurrentCamera local Char = Player.Character local Torso = Char:WaitForChild("HumanoidRootPart") local Mouse = Player:GetMouse() local TeleportRange = 450 game:GetService("UserInputService").InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.Z then local Distance = (Mouse.Hit.p-Torso.Position).Magnitude if Distance < TeleportRange then local xRot, yRot, zRot = Torso.CFrame:ToEulerAnglesXYZ(); Torso.CFrame = CFrame.new(Mouse.Hit.p) Torso.CFrame = CFrame.Angles(xRot, yRot, zRot); wait(0) else print("Too far") end end end)