so i made this script that shoots fire balls but every time his hp changes he shoots an extra ball in a loop instead of just one. can somebody pls help me
function gang()
wait(.05)
local hp = script.Parent.Parent.fire.Health
if hp <29999 then
while true do -- adds ball each time his hp changes idk why pls help me fix this part
local bomb = game:GetService("ServerStorage").bomb
wait(.001)
local throw = bomb:Clone()
throw.Position = script.Parent.Parent.UpperTorso.Position
throw.Parent = game.Workspace
throw.Anchored = true
wait(.001)
throw.Anchored = false
throw.Velocity = Vector3.new(0,-10,0)
local b = Instance.new("BodyVelocity")
b.Parent = throw
b.Velocity = script.Parent.Parent.LowerTorso.CFrame.LookVector * 120
b.MaxForce = Vector3.new(10000,10000,10000)
b.P = 1
wait(3)
throw:Destroy()
end
end
end
script.Parent.Parent.fire.HealthChanged:Connect(gang)

2 comments
i can try
that doesnt work bc his hp changes to fast, i need him to shoot 1 ball on a loop that is triggered by his hp changing once