hey i need help with a quick script! when u touch a part and u loose 25 health and if u touch it again u lose another 25 health Help!
COMMUNITY QUESTION
Touch a part and it removes 25 health everytime u touch it?
2 answers
Put this script in a Part
If this works please accept my answer.
local debounce = false
local HealthLoss = 25 -- Change this to the damage you need.
function OnTouched(Part)
if Part.Parent ~= nil then--Keep Parentless blocks from breaking it.
if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then
debounce = true
Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss)
wait(2)--Wait two seconds before the brick can hurt someone.
debounce = false
end
end
end
script.Parent.Touched:connect(OnTouched)
man, I'll give you this script, but this isn't a website where you just ask for a script and pronto, you need to put in effort yourself. Insert inside the part this script:
script.Parent.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
end
end)
I won't give you it next time if you don't put forth any effort.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Dude, the answer is good but you have got to assume that he has tried, I hate when people here criticize you for not knowing how to write a script. He probably has tried stuff but can't figure it out or maybe he just doesn't know where to start. This site was meant to be a place for people who are stumped to get help from others, that is what he has done. There's nothing wrong with his question.
that is true, I do thank you for correcting me, just I wish he put the script he has tried in there even if it's awful just to show he's tried. I will say I was wrong and thank you for telling me.
No problem, also I do understand what you are asking for and I totally get it but there is always the possibility that he just didn't know where to start. Anyway, I just wanted to say that, thanks for understanding and I want to be clear, I wasn't at all trying to attack you or anything I was just trying to make a point. :)
And it was a good one, totally see where your coming from, have a nice day.