Problems rotating the Character

Hello, I have this code that when the player enters the game the script changes the character’s position and rotates it, but in the part that rotates the character “PrimaryPart.Orientation = Vector3.new(0, 180, 0)” the character moves Backwards, I tried other methods, but none of them worked. The script is in the ServerScriptService.

Script:

 game.Players.PlayerAdded:Connect(function(Player)
	 Player.CharacterAdded:Connect(function(Character)
		 repeat task.wait() until Character.Parent == workspace
		 local Humanoid = Character:WaitForChild("Humanoid")
		 local PrimaryPart = Humanoid.Parent.PrimaryPart
		
		 PrimaryPart.Orientation = Vector3.new(0, 180, 0)
		
		 PrimaryPart.CFrame = CFrame.new(-478.115, 35.064, -50.953)
	 end)
 end)

I think you might be able to use PivotTo() to do it. You would just need to use

Character:PivotTo() --your cframe

Try changing orientation after CFrame.

Since CFrame is position and rotation, setting the CFrame also sets the rotation. You are undoing the orientation change by changing the CFrame afterwards.

Still walking backwards even with both methods

Are you able to make a video that demonstrates the problem?

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		repeat task.wait() until Character.Parent == workspace
		local Humanoid = Character:WaitForChild("Humanoid")
		local PrimaryPart = Humanoid.Parent.PrimaryPart
		
		PrimaryPart:PivotTo(CFrame.new(-478.115, 35.064, -50.953) * CFrame.Angles(math.rad(0),math.rad(180),math.rad(0)))
	end)
end)

Give this a try.

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