Player teleporting backwards

Hey there,
I have a script that forces the player to look left or right based on the Orientation of the humanoid root part.


It works well when going right (0,0,0) but when I turn around it just teleports me back. I didn’t even do any position changing.

local function Round(to_round,n)
	local divided = to_round / n
	local rounded = n * math.floor(divided)
	return rounded
end

script.Parent.OnServerEvent:Connect(function(Player,Character,o)
    --o = Character:WaitForChild("HumanoidRootPart").Orientation
	Character:WaitForChild("HumanoidRootPart").Orientation = Vector3.new(0,Round(o.Y,180),0)
end)

I am using a server script but I also used a localscript. Both had the same result.

Please help, is there anyone who can fix this? I think this may be an engine bug or something.

So you want the player to ONLY move left and right?

I already have the left and right movement. But if someone quickly presses one of the keys the player can sometimes get stuck looking backwards or forwards. So I want to rotate them to always be turned left or right.

Roblox’s weird orientation setting glitch completely ruins this.

me and a friend used this local script to make a 2d type game that I think you are aiming for

local cam = workspace.CurrentCamera
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
local cas = game:GetService("ContextActionService")
cas:UnbindAction("moveForwardAction")
cas:UnbindAction("moveBackwardAction")

game:GetService("RunService").RenderStepped:Connect(function()
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = cam.CFrame:Lerp(CFrame.new(hrp.Position + Vector3.new(0, 5, 15), hrp.Position), 0.1)
end)

note: if someone quickly moves left and right while against a wall they will move forwards or backwards. Also put this script in starter player scripts

What does this have to do with the teleportation though? This is only the script for moving the camera to look at the HumanoidRootPart.

I think the information you give is too little to make an assesment about anything, but my first concern is that you seem to be using a remotevent to handle the orientation on the server side? Why not on the localscript?

I can see this causing desync issues due to ping

1 Like