Ball fall physics relative to mouse position and gravity

I am making this Tool that shoots out a ball like a normal dodgeball. it works fine but I want it shoots out relative to the height or position of the Mouse rather than having a fixed Unit or MaxForce from BodyVelocity.

Proof:

Code:

local ball = Instance.new("Part")
	ball.Shape = 0
	ball.Material = Enum.Material.SmoothPlastic
	ball.Anchored = false
	ball.CanCollide = true
	ball.Transparency = 0.25
	ball.CFrame = DodgeBall.Handle.CFrame
	ball.Parent = workspace
	ball.Name = "ball"
	ball.Size = Vector3.new(2, 2, 2)
	local DENSITY = 0.5
	local FRICTION = 0.5
	local ELASTICITY = 1
	ball.CustomPhysicalProperties = PhysicalProperties.new(DENSITY, FRICTION, ELASTICITY)
	
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.MaxForce = Vector3.new(math.huge, workspace.Gravity, math.huge)
	BodyVelocity.Velocity = (HitLocation.Position - DodgeBall.Handle.Position).Unit * 200
	BodyVelocity.Parent = ball
	
	Debris:AddItem(ball, 10)
1 Like

You could try raycasting from the player to the mouse position, and set the ball’s velocity to the direction of that raycast

1 Like