I've been working on my first magic script lately, and I've just noticed this "bug" or unwanted feature which is inaccuracy. This issue is so bad at the point the projectile can go over 100 studs away from the desired target.
This is the piece of code I've used that I am almost certain that contains the issue:
local bodyvel = Instance.new("BodyVelocity", Projectile) bodyvel.MaxForce = Vector3.new(math.huge,math.huge,math.huge) bodyvel.Velocity = Mouse.lookVector * 150 -- Mouse in here is abbreviated for Mouse.Hit.Cframe.
Here's a streamable link to a video where it's inaccuracy is shown. https://streamable.com/yiayq5
It really frustrated me. (It was supposed to land near the place with bent pillars.)
Wow! That video looked pretty cool! I suggest using Rays, Rays are a lot more accurate. (unless there is an invisible object in the way) Anyways, this is a basic script that should help:
local Workspace = game:GetService("Workspace") local position = mouse.Hit.Position local origin = YOUR_STARTING_PART.Position local direction = (position - origin).Unit*300 local result = Workspace:Raycast(origin, direction) local intersection = result and result.Position or origin + direction local distance = (origin - intersection).Magnitude local bullet_clone = LOCATE_PROJECTILE_HERE bullet_clone.CFrame = CFrame.new(origin, intersection)*CFrame.new(0, 0, -distance/2) bullet_clone.Parent = Workspace
You can play around with it, let me know if you have any questions!