Script works but output spams errors

I’m trying to make the player face the direction they’re blocking in and it works, but the output spams “The Parent property of lookGyro is locked, current parent: NULL, new parent HumanoidRootPart”. I’ve tried to parent the gyro to nil instead of destroying it, but it stays in the root-part and the character is stuck facing one direction. I could be dumb and be overlooking something but I don’t know.

video -
https://gyazo.com/917fc253d92fbf9ae7d15cec6580063b

uis.InputBegan:Connect(function(input)
	if not on then return end

	if input.UserInputType == Enum.UserInputType.MouseButton2 then
	lookGyro = Instance.new("BodyGyro")
	lookGyro.Name = "lookGyro"
	lookGyro.MaxTorque = Vector3.new(1,1,0) * 100000
	lookGyro.D = 100	
		blocking:Play()
		tool.emitter.Inner.Trail.Enabled = true
		if blocking.IsPlaying then
			local function renderstep(dt)
			lookGyro.Parent = root
			lookGyro.CFrame = CFrame.new(root.CFrame.Position, root.CFrame.Position + Vector3.new(camera.CFrame.LookVector.X, 0, camera.CFrame.LookVector.Z))
				humanoid.AutoRotate = false
				wait()
			end
			humanoid.WalkSpeed = 10
			runService.RenderStepped:Connect(renderstep)
		end
		wait(0.3)
		tool.emitter.Inner.Trail.Enabled = false
	end
end)

uis.InputEnded:Connect(function(input)
	if not on then return end
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		humanoid.WalkSpeed = 16
		lookGyro:Destroy()
		blocking:Stop()
		humanoid.AutoRotate = true
	end
end)	```

Have you tried looking into this thread?

yes, but I don’t know how to go about fixing it

You deleted lookGyro, instead of using :Destroy(), use .Parent = nil

I already tried .parent = nil it makes the character stuck in one direction

I’m pretty sure it is because of the constant parenting of lookGyro in RenderStepped. Try not to parent it constantly.

that worked. now the gyro disappears from the root part, but my character is still stuck facing one direction.

Remove the gyro on unequip. Hopefully that works.

yeah, my character is still stuck facing a direction.

Can you check your character’s children, just in case something is interfering with your character.

everything else is there and fine

so sorry I’ve put you through the hassle of trying to help me, but I figured out that autorotate was set to false and was making my character face one direction. thanks anyway.

1 Like