Player CFrame doesn't rotate all the way

this script suppose to make the player rotate to the front or the back when they press W or S, rotatting to the front seems to be working all right but when i tried to make them rotate to the back it just stop at like 135 degrees angle, like this:

External Media

^ i swear is a video and not a virus

Script:


local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
local humanoidrootpart = character:FindFirstChild("HumanoidRootPart")

UIS.InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.W then
		local goal = {}
		goal.CFrame = CFrame.new(humanoidrootpart.Position) * CFrame.Angles(0, 0, 0) 
		local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back)

		local tween = TweenService:Create(humanoidrootpart, tweenInfo, goal)

		tween:Play()
	end
	if input.KeyCode == Enum.KeyCode.S then
		local goal = {}
		goal.CFrame = CFrame.new(humanoidrootpart.Position) * CFrame.Angles(0, -180, 0)
		local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back)
	
		local tween = TweenService:Create(humanoidrootpart, tweenInfo, goal)

		tween:Play()
	end
end)
1 Like

Change it to:
CFrame.Angles(0, math.rad(-180), 0)

1 Like

btw is there a way to only tween the angles, im tweening both character position and angles

1 Like

I did research and it is recommended to tween CFrame just to change orientation. But hey, trying to tween just orientation will not hurt.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.