Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Touch a part and it removes 25 health everytime u touch it?

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!

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.

4 comments

0

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.

0

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.

0

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. :)

0

And it was a good one, totally see where your coming from, have a nice day.

This discussion is preserved as it was. New answers, comments, and votes are closed.