BodyGyro breaking autorotate?

I’m using a bodygyro to align hrp cframe to the wall so they’re facing the right way

Everything’s getting destroyed right, but this is my first time using bodygyros. I’m not too sure why it’s not letting my humanoidrootpart rotate correctly after it’s destroyed.

https://gyazo.com/bfe62a3b7974ea811cdf071f0aa10e43

        local Gyro = Instance.new('BodyGyro')
        Gyro.Parent = HRP
        Gyro.D = 100
        Gyro.P = 10000
        game.Debris:AddItem(Gyro,1)
        
        local Velocity = Instance.new("BodyVelocity")
        Velocity.Parent = HRP
        Velocity.MaxForce = Vector3.new(0,0,0)
        game.Debris:AddItem(Velocity,1)
        
        local monkey
        monkey = game:service("RunService").RenderStepped:connect(function()
            Gyro.CFrame = HRP.CFrame
            Gyro.MaxTorque = Vector3.new(1,1,1) * math.huge
            Velocity.MaxForce = Vector3.new(1,1,1) * math.huge
            if saidochesto == "right" then
                Velocity.Velocity = -cross * Humanoid.WalkSpeed
                HRP.CFrame = CFrame.new(Vector3.new(HRP.Position.x, HRP.Position.y, HRP.Position.z), Vector3.new(HRP.Position.x - cross2.x, HRP.Position.y, HRP.Position.z - cross2.z))
            elseif saidochesto == "left" then
                Velocity.Velocity = cross * Humanoid.WalkSpeed
                HRP.CFrame = CFrame.new(Vector3.new(HRP.Position.x, HRP.Position.y, HRP.Position.z), Vector3.new(HRP.Position.x + cross.x, HRP.Position.y, HRP.Position.z + cross.z))
            end
            if not Velocity or not Gyro then
                monkey:Disconnect()
            end
        end)

any ideas on why it’s doing this? what am I doing wrong?

I just read up on this.
I think you forgot to use GetService.
local Debris = game:GetService("Debris")
I could be completely wrong, just got it straight from the wiki.

naw, it wouldnt delete correctly if debris didn’t go through

u can use the service by doing game.Debris too

1 Like

-You’re deleting the gyro one second after instantiating it.-
Physics objects only influence objects in the world when they exist as a descendant of the world.

-Remove the gyro from Debris.-

Also, if you want to prevent the Humanoid from rotating when the player moves. Set the Humanoid.AutoRotate to false or true when you need it.

-correction, I think I see what you’re doing.
Set the CFrame of the Gyro to the HRP’s CFrame when you create it

Try also reducing the amount of force applied to both the gyro and velocity, you don’t need math.huge for that and your character is probably being thrown to the null zone because of it.

1 Like

i did wat u said, i think i found out what the real issue is, I think the renderstepped loop that’s controlling the humanoidrootpart’s CFrame as U can see here:

		local monkey
		monkey = game:service("RunService").RenderStepped:connect(function()
			Gyro.CFrame = HRP.CFrame
			Gyro.MaxTorque = Vector3.new(10000,10000,10000)
			Velocity.MaxForce = Vector3.new(10000,10000,10000)
			if saidochesto == "right" then
				Velocity.Velocity = -cross * Humanoid.WalkSpeed
				HRP.CFrame = CFrame.new(Vector3.new(HRP.Position.x, HRP.Position.y, HRP.Position.z), Vector3.new(HRP.Position.x - cross2.x, HRP.Position.y, HRP.Position.z - cross2.z))

i think it might not be stopping right, I just had this idea a moment ago, maybe I’m not setting the HRP’s frame back to normal once it’s done?

nvm, it’s def the bodygyro, i’m really stumped man, I swear this is gonna be the first and last time I’m using bodygyros LOL

WAIT IT’S NOT WTF
hang onnnnnnnnnnn no wayy

found the solution, IT WAS THE BODYVELOCITY. I refrained from using debris to destroy the bodyvelocity, used tick() to estimate when a second had passed, after that I set the maxvelocity to 0 and set the parent to nil, then destroyed. worked.

2 Likes