Hi , I have made this simple Fireball Ability But after some testing i found out the Accuracy can be broken some times . Do you know how can I improve it ?
function StartSkill(plr,char,mousehitPos)
local part = workspace:FindFirstChild("FireBall_Part") -- Fire Ball Part That will move
local EndPart = workspace:FindFirstChild("End") -- The Red Part And Pos of the mouse hit
if not part then return end
local at0 = Instance.new("Attachment",part)
local spd = Instance.new("BodyVelocity",part)
local distance = (mousehitPos-part.Position).Magnitude
local DisTest = (mousehitPos-part.Position)
EndPart.Position = mousehitPos
part.BrickColor = BrickColor.new("White")
spd.P = 10000000
spd.MaxForce = Vector3.new(1000000,1000000,1000000)
spd.Velocity = Vector3.new(0,0,0)
spd.Velocity = (mousehitPos - part.Position) /distance * 50
print(distance)
print(DisTest)
part.Anchored = false
end
local FireStart = script.Parent.Events:FindFirstChild("ActivateSkill") -- idk what is this
FireStart.OnServerEvent:Connect(StartSkill) -- when the player click with tool on any place >> fire the function
and the green part dosen’t do anything except just destroying the ball and Spawning it again , Thx .