Make a part move towards a part using LinearVelocity

So, I used to have this system for a game where you could make a spell cast towards the mouse position using body velocity, and it was a OK. But only recently did I want to remake this system to find out that Body Velocity is deprecated and I wanted to try out the new “Improved” version LinearVelocity. I’ve been trying to figure out how I could achieve a similar result but to no avail.

This is the old code I used to work with

local velocity2 = Instance.new("BodyVelocity", bh)
	velocity2.Velocity = CFrame.new(bh.Position, mousepos).LookVector * 100
	velocity2.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

mousepos in that script is equal to mouse.Hit.LookVector, although I could change that if needed.

My question is how would I make it so that the linear velocity goes in the direction of the mouse position.

1 Like

Ended up figuring out, if anyone ever runs into this issue :
velocity.VectorVelocity=(mousepos.Position-bh.Position).Unit*Speed

10 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.