Character rotation issue

Hello, in my game I have a system where you can pause/unpause. When you pause, it stops the character in its tracks. When the character unpause, it should flow right back into movement, and the player controlling it, however there is an odd glitch where the player will start at a rotation of 0,0,0 whenever you unpause. Here is the code section that deals with the actual character.

function CharAnchor(Character, player)
local anchorBool = false
if player.isPaused.Value then anchorBool = true else anchorBool = false end
for _, CharacterPart in pairs(Character:GetChildren()) do
if CharacterPart:IsA(“BasePart”) then
CharacterPart.Anchored = anchorBool
CharacterPart.Velocity = Vector3.new()
CharacterPart.AssemblyLinearVelocity = Vector3.new()
CharacterPart.AssemblyAngularVelocity = Vector3.new()
if CharacterPart.Name == “HumanoidRootPart” then
if anchorBool then
player:SetAttribute(“SavedRotation”, CharacterPart.Orientation.Y)
else
local savedRotation = player:GetAttribute(“SavedRotation”)
if savedRotation then
CharacterPart.CFrame = CFrame.new(CharacterPart.CFrame.Position) * CFrame.Angles(0, savedRotation, 0)
player:SetAttribute(“SavedRotation”, nil)
end
end
end
end
end
end

I took some of this code from another post, but then added upon it myself.

1 Like

Please post your code with 3 backtics (```) before and after the code to keep the proper formatting.

Doesn’t it save in the same Position and Rotation if you just Anchor and Unanchor the Parts of the Player? The CFrame and Rotation shouldn’t change so you shouldn’t need to save and reset them each time.

I believe in other posts I’ve seen about player manipulation you may need to do it in each frame while the player needs to be frozen, but don’t quote me on that.

Even when it’s only the anchoring line, the issue still occurs.

also here is the code with the better formatting

	local anchorBool = false
	if player.isPaused.Value then anchorBool = true else anchorBool = false end
	for _, CharacterPart in pairs(Character:GetChildren()) do
		if CharacterPart:IsA("BasePart") then
			CharacterPart.Anchored = anchorBool
			CharacterPart.Velocity = Vector3.new()
			CharacterPart.AssemblyLinearVelocity = Vector3.new()
			CharacterPart.AssemblyAngularVelocity = Vector3.new()
			if CharacterPart.Name == "HumanoidRootPart" then
				if anchorBool then
					player:SetAttribute("SavedRotation", CharacterPart.Orientation.Y)
				else
					local savedRotation = player:GetAttribute("SavedRotation")
					if savedRotation then
						CharacterPart.CFrame = CFrame.new(CharacterPart.CFrame.Position) * CFrame.Angles(0, savedRotation, 0)
						player:SetAttribute("SavedRotation", nil)
					end
				end
			end
		end
	end
end```

I found the problem. (char limit)

Please post your answer and mark it as the Solution.
It may help anyone searching for an answer to a similar problem they might be having.

function paws(Character)
	local humanoid = Character:WaitForChild("Humanoid")
	if humanoid.WalkSpeed == 0 then
		humanoid.WalkSpeed = 16
	else humanoid.WalkSpeed = 0
	end
end

No rotation problem. Just a simple pause (paws).
This not only “stops the character in its tracks”, but also stops the running animation.
(if they happen to be running at the moment)

SOLUTION: I was changing the players position on the client after changing it once on the client and again on the server.

1 Like

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