-
What do you want to achieve?
Fixing my projectile script so that it doesn’t glitch. -
What is the issue?
Projectile randomly stops and glitches.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Rescripting
--workspace.ignore is where fireball part and explosion part is parented to
local FireballOverlapParams = OverlapParams.new()
FireballOverlapParams.FilterType = Enum.RaycastFilterType.Exclude
FireballOverlapParams.FilterDescendantsInstances = { workspace.Ignore, character}
local connection
local startTime = os.clock()
local hit = false
local humanoid = nil
connection = RunService.Heartbeat:Connect(function(dt)
local direction = (mouseHit.Position - Fireball.Position).unit
Fireball.CFrame = CFrame.new(Fireball.Position) + direction * dt * 80
local hitParts = workspace:GetPartsInPart(Fireball, FireballOverlapParams)
if #hitParts ~= 0 then
hit = true
--explosion function here
for i, v in ipairs(hitParts) do
if v.Parent:FindFirstChild("Humanoid") then
humanoid = v.Parent:FindFirstChild("Humanoid")
end
end
end
if hit then
if humanoid then
humanoid:TakeDamage(15)
--knockback function here
end
connection:Disconnect()
--fireball particles disabled here
wait(3.5)
Fireball:Destroy()
end
Fireball.CFrame = CFrame.new(Fireball.Position) + direction * dt * 80
if os.clock() >= startTime + 4 then
connection:Disconnect()
--fireball particles disabled here
wait(3.5)
Fireball:Destroy()
return
end