Best way to temporarily disable a Body Mover?

Hey everyone. I was looking for an alternative to a BodyMover.Enabled = false (which I wish existed). That’s the short of it but here’s why I’m doing that:

I have a targeting system where a BodyGyro in the players HumanoidRootPart is updated towards the nearest player on every render step. Since I am using Run Service that’s all happening on the client. I also implemented a dodge feature that simply applies a Body Velocity in the direction of the player’s stick/keys. During that dodge I want a new BodyGyro to be applied that rotates the character in the direction of the dodge. This works fine, but only when I remove the BodyGyro attached to the Render Step.
I could easily just change the parent temporarily while the dodge BodyGyro is present but is that really the most efficient way to do it? It feels like their must be a better way!

1 Like

Have you tried to set the BodyGyro.MaxTorque = Vector3.new(0,0,0)
This should disable the Gyro and after using your dodge and removing the dodge gyro just set the main gyro back to the previous MaxTorque?

I was worried about doing that only because I’d have to be setting it on every render step which I’m assuming would be fairly costly.

Use a boolvalue set it to true when you are dodging and put it outside the render step with connect function

Something like this:

local bodygyrotorq = Vector3.new(40000,40000,40000)  -- used for base torq
workspace.Dodged.Changed:Connect(function()
	if workspace.Dodged.Value then  -- if it is set to true
		BodyGyro.MaxTorque = Vector3.new()  -- sets to 0,0,0
	else
		BodyGyro.MaxTorque = bodygyrotorq
	end
end)


workspace.Dodge.Value = true   -- sets it for dodging and to 0,0,0 torq

workspace.Dodge.Value = false -- sets to not dodging and back to base torq
1 Like

Ah that’s a great way to do it. Thanks for the help!

1 Like