#How can I make an npc deal damage when touching a player?

5 messages · Page 1 of 1 (latest)

opaque grove
#

I need my zombie to deal damage when touching a player, can someone tell me how?

quiet thistle
#

local damageAmount = 10

local function onTouched(other)
    local character = other.Parent
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    
    if humanoid then
        humanoid:TakeDamage(damageAmount)
    end
end

zombie.Touched:Connect(onTouched)
quiet thistle
#

damn

#

Make sure the script is placed inside the zombie model in Roblox Studio. It should be a child of the zombie.