I am trying to make a cannon but I don't know how to launch the cannonball.
What do i need to add to a script to give an object momentum when it spawns?
1 answer
What you could do is utilize BodyMovers to add a velocity to a Part.
BodyVelocity will help you in this case as it applies velocity to a Part at a constant rate. Here's an example of how you could use a BodyVelocity to "launch" a part.
First, you define your BodyVelocity by creating one:
local bodyVelocity = Instance.new("BodyVelocity")
Make sure you define the Part you want to launch as well. Next, parent the BodyVelocity to our Part. This will define the part we want to be affected by the velocity. Also, we will change the MaxForce so our Part can be affected more easily by the body mover.
local bodyVelocity = Instance.new("BodyVelocity")
local cannonball = workspace.Cannonball
bodyVelocity.MaxForce = Vector3.new(10000, 10000, 10000)
bodyVelocity.Parent = cannonball
Now, we set the Velocity property of the BodyVelocity. It is a Vector3, so it will take X, Y, and Z values. We'll use a function to do this.
local bodyVelocity = Instance.new("BodyVelocity")
local cannonball = workspace.Cannonball
bodyVelocity.MaxForce = Vector3.new(10000, 10000, 10000)
bodyVelocity.Parent = cannonball
function launch()
bodyVelocity.Velocity = Vector3.new(100, 100, 0)
wait(2)
bodyVelocity.Velocity = Vector3.new(0, 0, 0)
end
launch()
We now have a function that will apply a force of 100 on the X and Y axis on the part, wait 2 seconds, and then stop applying that force.
If you want more or less force on the ball, you can change the numbers to your liking.
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
this is not a request site post your script you made so far
Like @AlbertoMiAmigo2 said, this isn't a request site. If you want to launch the cannonball though, I'd suggest researching body movers.
didn't mean it as a request sorry if it seemed like that and thx tho
hes asking for how to launch it... not for someone to make a cannon for him... @blocktaco