Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to apply a force to an anchored part?

I have a part spinning with the use of a BodyAngularVelocity. However, I need such an action to be performed while the part is in the air, not while hitting the baseplate, so I am anchoring it when it is in the air- but this breaks the force, the part stops spinning while anchored. How can I exert a force on an anchored object, or exert a force which leaves my part spinning in the air in the position I specify?

2 answers

You could try a BodyPosition, which continually applies force to an object to move it back to a specified position.

function makeHover(part)
    local bodyPosition = Instance.new("BodyPosition", part)
    bodyPosition.Position = part.Position
end

Alternatively, you could counteract the forces of gravity with a BodyForce.

function makeHover(part)
    local bodyForce = Instance.new("BodyForce", part)
    bodyForce.Force = Vector3.new(0, part:GetMass() * workspace.Gravity, 0)
end

Finally, you could keep the part anchored, but use CFrame to rotate it gradually.

function makeHover(part)
    for i = 0, math.pi * 2, math.pi / 64 do
        part.CFrame = part.CFrame * CFrame.Angles(0, math.pi / 64, 0)
        wait(0.2)
    end
end

You cannot exert a force on an anchored part, as it is completely exempt from physics when anchored. In order to keep it in the air, look into BodyPosition or BodyForce, as these can help keep your object in the air. BodyPosition allows you to specify a position for your object to go to and stay at, while BodyForce acts as a constant force for/against/neutral to gravity.

This discussion is preserved as it was. New answers, comments, and votes are closed.