Make momentum based power | Touch soccerBall

I am trying to achieve a momentum based power system whenever the soccer is touched. Right now currently, I have a set vector for walkspeed however I am attempting to make the ball so if the player contacts the ball at 12.58 walkspeed, then the force will apply itself accordingly to get a different distance shot everytime.

I am relatively new to LUA, roughly just under intermediate, however I am unsure how to even begin to apply momentum based force. Do you have any suggestions fellas?

(Also if you have resources for anything related to this topic, please include them for me, thank you!)

https://developer.roblox.com/en-us/api-reference/property/BasePart/AssemblyMass
Multiply mass by velocity to get the momentum. Then depending on how you want to apply that force, you integrate the momentum into the equation

Example of a function:

``````local offset: Vector3 = Vector3.new(0, -3, 0) --so that the ball actually goes up in the air when it's kicked
local defaultMult: number = 100 --so that the ball actually moves lol
function kickBall(playerHRP: BasePart, ball: BasePart)
assert(playerHRP and ball, 'missing parameters')
local pVel: Vector3 = playerHRP.AssemblyLinearVelocity
local dir: Vector3 = (ball.Position - (playerHRP.Position + offset)).Unit --normed displacement
local relMult: number = dir:Dot(pVel.Unit) --angle between velocity and dir
local force: Vector3 = dir * relMult * playerHRP.AssemblyMass * defaultMult
ball:ApplyImpulse(force)
end
``````

Once again, this is just an example. You will have to add in extra checks to make sure the player doesnâ€™t kick the ball twice at once, etc.