I'm trying to make a projectile go towards my mouse's location, but I can't get it to work properly. I'll include part of my script as the entirety of it is quite large.
local mouse = player:GetMouse() local projectile = game:GetService("ReplicatedStorage"):Clone() projectile.CFrame = char.LowerTorso.CFrame local bv = Instance.new("BodyVelocity") bv.Parent = projectile bv.MaxForce = Vector.new(math.huge,math.huge,math.huge) bv.Velocity = mouse.Hit.CFrame * 50
Any and all help appreciated!
First of all, you are never parenting the projectile. Also, to make the BodyVelocity aims towards the mouse's location, you have to use the lookVector
property of mouse.Hit.
local mouse = player:GetMouse() local projectile = game:GetService("ReplicatedStorage"):Clone() projectile.Parent = workspace -- parent the projectile to workspace projectile.CFrame = char.LowerTorso.CFrame local bv = Instance.new("BodyVelocity") bv.Parent = projectile bv.MaxForce = Vector.new(math.huge,math.huge,math.huge) bv.Velocity = mouse.Hit.LookVector * 50 -- use lookVector
Let me know if you have any more questions or need help!