Throw ball on click?
Asked by
8 years ago Edited 8 years ago
I am trying to make a ball that can be "owned" by a player (if so, it gets welded to the owner's Right Arm - like a tool), or, if not owned by anyone, slowly fall to the ground.
To "own" the ball, you simply have to touch it (disregarding if it's owned by someone else or not).
The "owning" part seems to be working fine, but I need it to be thrown on click, heading to the direction the player clicks (i.e., if the player is facing the left side, but clicks on the right side, it gets thrown to the right side, exactly to the direction to which the player clicked).
I need it to reach a certain speed and then slow down until it stops.
I am awful with BodyMovers, so I probably did everything wrong.
A small summary of my current code is below:
04 | local GravityBodyForce = Instance.new( "BodyForce" , quaffle) |
05 | GravityBodyForce.force = Vector 3. new( 0 , game.Workspace.Gravity/ 1.25 , 0 ) * quaffle:GetMass() |
09 | function onClick(plr, firePos) |
12 | if owner.Value~ = plr then return end |
15 | dontAcceptNewOwners = true |
16 | local force = Instance.new( "BodyForce" , quaffle) |
17 | force.force = firePos * quaffle:GetMass() |
20 | dontAcceptNewOwners = false |
Please help!
Thanks in advance.