Projectile damage not occuring


I made this script so that whenever anything other than the player and tool is hit, it deals damage. However, it doesn’t work. It works randomly. Anyone know why?

Have you checked the script is fully right and coding is correct? Sometimes you have to check you scripted it to the right model and Mostly, I’m thinking you have did the scripting wrong or have’t placed the script on the model right. I’m not a scripted myself just suggested that to check through it or re do the script.

I’ve checked everything thoroughly before posting on the forum.

Maybe you can use workspace:GetPartsInPart() in a loop like:

local RunService = game:GetService("RunService")

local part = script.Parent

local overlapParams = OverlapParams.new()
overlapParams.FilterDescendantsInstances = {part}
overlapParams.FilterType = Enum.RaycastFilterType.Exclude

RunService.Heartbeat:Connect(function()
    local parts = workspace:GetPartsInPart(part, overlapParams)

    for i,v in ipairs(parts) do
        local character = v:FindFirstAncestorOfClass("Model")

        if character then
            local humanoid = character:FindFirstChildOfClass("Humanoid")

            if humanoid then
               humanoid:TakeDamage(20)
            end
       end
    end
end)

Oh I apologize, I forgot to close this. I solved it. Turns out the fireball was being destroyed before it could hit the player, thus I added a delay to the tween.Ended event.

Thank you for your help though!

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