I tried to make a successful lava script where when you touch it, it damages a user 25 HP. I tried to make it, and it just won't kill a user.
Here is the script I started with, before it got more complex:
function onTouch(part)
I haven't found an error there, but it did nothing. Here's another part:
local humanoid = findFirstChild("Player")
The third part is where I'd assume that I messed up. I'd need a developer to help me here:
if (humanoid ~onTouch) then
humanoid.health~(-25)
And finally, incase you need it, here's the last part:
end
end
script.Parent.Touched:connect(onTouch)
The sum of it all is this:
function onTouch(part)
local humanoid = findFirstChild("Player")
if (humanoid ~onTouch) then
humanoid.health~(-25) --The '25' there is a negative number to show the loss of 25 Health Points, however it may be impossible to add into a script...
end
end
script.Parent.Touched:connect(onTouch)
If I can get the script to be correct and damage the user, that would be great. It just doesn't work for me, and I'd like some help. Thank you for your time.

2 comments
Exactily what I was looking for. Deep explanations and correct coding. Thank you so much and thank you everyone who posted.
No problem man. :) Glad to help. ;D