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:
-- quaffle variable points to the ball -- set gravitational pull to less local GravityBodyForce = Instance.new("BodyForce", quaffle) GravityBodyForce.force = Vector3.new(0, game.Workspace.Gravity/1.25, 0) * quaffle:GetMass() -- owner is an ObjectValue that points to the Player Instance that "owns" the ball function onClick(plr, firePos) -- plr: Player who clicked -- firePos: Mouse.Hit.p at time of click if owner.Value~=plr then return end owner.Value = nil updateOwner() -- Gets rid of the weld, since owner.Value is nil dontAcceptNewOwners = true local force = Instance.new("BodyForce", quaffle) force.force = firePos * quaffle:GetMass() wait(1) force:Destroy() dontAcceptNewOwners = false end
Please help! Thanks in advance.
Most people would just use a bodyvelocity, but actually applying forces is fine. They're both vectors so you can use them similarly.
force.force = firePos * quaffle:GetMass()
Doesn't really make sense though. Force is a vector which is a direction multiplied by a magnitude. firePos is a position, not a direction.
To get direction: local direction = (firePos - plr.Character.Head.Position).unit
This is where the character is looking, even in third person. Then you multiply that by how much force you actually want to apply. I hope this helps!