The script below makes the part disappear after being touched by anything, which is a problem. But I don't know how I will make it so it will only disappear after being touched by a certain object.
health = script.Parent.Parent.Parent.Health local debounce = false function onHit() if debounce == false then debounce = true health.Value = health.Value - 10 print (health.Value) wait(3) debounce = false script.Parent:Destroy() end end script.Parent.Touched:connect(onHit)
Touched has an optional argument to see what touched it, for example if you wanted to see if the toucher had a Humanoid inside
function onHit(toucher) if toucher.Parent:FindFirstChild("Humanoid") then print("This part was touched by something with a humanoid inside") end -- or you could filter by name, etc if toucher.Parent.Name == "someSpecialPart" or toucher.Name == "someSpecialPart" then print("This part was touched by someSpecialPart") end end script.Parent.Touched:Connect(onHit)