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

Can someone help me make a brick that when touched does 17 damage to player?

im trying to make a script so that when you touch a part, it damages you (-17 health) here is what ive tried with what i learned so far, but it doesnt work plz help

	repeat
	game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health = game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health-17
	until script.Parent.TouchEnded

Plz help Dx

2 comments

0

I would urge you to look for free models and to read and comprehend the scripts yourself. The script you're showing us right now is meaningless.

0

wow rlly helpful, Thanks C: sarcasme

2 answers

Put this script inside of a brick/part.

script.Parent.Touched:Connect(function(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid") -- if the part finds a humanoid, we know it's a player touching the brick
	if (humanoid ~= nil) then -- if the humanoid exists
		humanoid:TakeDamage(17) -- damage the humanoid by 17
	end
end)

1 comment

0

it works, but i want it to damage you like every 3 seconds and when i stop touching it, it still damages me :/

script.Parent.Touched:Connect(function(part)
CantTouchMe=false
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil and CantTouchMe==false) then 
        humanoid:TakeDamage(17) -- damage the humanoid by 17
	CantTouchMe=true
wait(3)
CantTouchMe=false
    end
end)

1 comment

0

same problem, it glitches like every mili-second it goes from 63 to 120-160

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