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

Make a part that when you touch it it will make you take damage?

I need help making a part that will make you take damage if you touch it. Thanks!

function onTouch(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
		Character.Humanoid:TakeDamage(10)
		script.Parent:Destroy()
	end
end

script.Parent.Touched:Connect(onTouch)

1 answer

✓ Accepted answer

This script doesn't work because "Character" is not defined anywhere. It will work if you define Character as hit.Parent, or if you replace line 4 with hit.Parent.Humanoid:TakeDamage(10)

1 comment

0

Thank you!

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