Is there a way to improve/Fix this Fireball Ability Accuracy?

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 .

BodyVelocity deprecated use new containers

local alignPosition = Instance.new("AlignPosition")
alignPosition.Parent = sphere
alignPosition.ApplyAtCenterOfMass = true
alignPosition.MaxForce = 10000 -- Adjust this value to change the strength of the constraint
alignPosition.MaxVelocity = math.huge -- Allows the sphere to move as quickly as possible
alignPosition.Responsiveness = 50 -- Adjust this value to change how quickly the sphere will move towards the target position
alignPosition.RigidityEnabled = true
alignPosition.TargetPosition = targetPosition
1 Like

won’t this make the sphere speed change with time ?

I want the speed of it to be fixed so i can adjust it for every ability

It’s up to you, you need to update the position of the constraint according to the formula, and the constraint will move the sphere

Thanks a lot it’s much better now , I will just need to Adjust The speed .
Thx Again

1 Like

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