Lava Block Code Not Working

Hi, I’m trying to code a lava block (kill block) that when you touch it slowly does damage. it’s not working and I’m not sure why (sorry I’m really new at coding) Heres the code

local Lava = script.Parent
local DamageAmount = 10

local function DealDamage(part)
local hum = part.Parenet:FindFirstChild(“Humanoid”)
if hum then
hum.Heath = hum.Heath - DamageAmount

end

end

LavaBox.Touched:Connect(DealDamage)

Try changing LavaBox to Lava? You never defined LavaBox.
(So like here: ↓)

So replace that with:
Lava.Touched:Connect(DealDamage)

Hope this helped! (・ω・)b

1 Like

Well, firstly when using a block of code say ```lua at the start then the same without lua at the end. LavaBox is what you use for the touch event, however LavaBox is not defined, try using Lava.Touched. Also where you use local hum = part.Parenet:FindFirstChild(“Humanoid”), you should be saying part.Parent not Parenet.

2 Likes

Thanks were would a put the Lava.Touched in the script?

You replace that part there with Lava.Touched:Connect(DealDamage)

2 Likes