✓ Accepted answer
With roblox physics, you don't only touch an object once.. you "bounce" on the object; therefore, touching it 5, 6, 7, etc.. times. Due to this, often times a Debounce is set up.
A debounce essentially prevents the code from firing multiple times, even if the event is fired multiple times. A debounce makes it so you check a value before continuing the code. If this value is false then turn it true and do the code. If it's true then do nothing.
Set up a debounce in your code, and disable it after one second.
Also, on line 4, you were just setting the health value to -10. To subtract 10 health you need to set the value relatively to itself. So you set the health value to the health value minus 10; health = health - 10
local db = false
function lava(hit)
if not db then
db = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then
humanoid.Health = humanoid.Health -10
end
wait(1)
db = false
end
end
script.Parent.Touched:connect(lava)