How to apply a force to a part?

I want to eject bullet casings from when a gun is fired, how do I apply a sideways force to the bullet casing so that it looks like its being ejected out of the gun?

You can apply an impulse to it or just set the AssemblyLinearVelocity. If you’re using a Part welded to the weapon model to indicate the relative CFrame of the ejection port, something like this should work:


local shellCasingPrefab = game.ReplicatedStorage -- ...fill in
local ejectionPort = gunModel.EjectionPort

function ejectShellCasing()
    local shellCasing = shellCasingPrefab:Clone()
    shellCasing:ApplyImpulse(ejectionPort.CFrame.RightVector * SHELL_CASING_EJECTION_SPEED)
1 Like

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