Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My damage function doesn't quite work, help?

local weapon = script.Parent
local damage = 15

weapon.Blade.Touched:Connect(function(plr)
    local Humanoid = script.Parent:FindFirstChild("Humanoid")
    
    if Humanoid then
        Humanoid.TakeDamage = Humanoid.TakeDamage(15)
    end
end)

When I test this game out, it doesn't deal any damage to any of the dummies, I know a lot of my code is wrong but not too sure where it is wrong.

Any help/ info would be appreciated :)

1 answer

✓ Accepted answer

Always check for the player and you never even used the (plr) arg in that function.

On top of that your script said

local weapon = script.Parent

and

local Humanoid = script.Parent:FindFirstChild("Humanoid")

So look out for stuff like that lol.

local weapon = script.Parent
local damage = 15

weapon.Touched:Connect(function(TouchedPart)
    if TouchedPart ~= script.Parent.Parent.Parent then
        if TouchedPart.Parent:FindFirstChild("Humanoid") then
            local Hum = TouchedPart.Parent:FindFirstChild("Humanoid")
            Hum:TakeDamage(5)
        end
    end
end)

6 comments

0

Still doesn't seem to work.. do you want a screenshot of my explorer tab?

0

sure

0

Forp #0001

0

k

0

thank

0

ofc

This discussion is preserved as it was. New answers, comments, and votes are closed.