So I want to use the function I made but only if the part is touched by a part named "Bullet" I have this:
debounce = false health = script.Parent.Parent.Health function onTouch(hit) if debounce == false then debounce = true health.Value = health.Value - 1 debounce = false end end script.Parent.Touched:connect(onTouch)
So, how do I use the function if only the part that touched it is named "Bullet"?
debounce = false health = script.Parent.Parent.Health function onTouch(hit) if debounce == false then if hit.Name == "Bullet" then --The conditional statement that checks if the name of the part is Bullet. "hit" is the name of the part that touched script.Parent, which is the part I'm assuming that you want to check. debounce = true health.Value = health.Value - 1 debounce = false end end script.Parent.Touched:connect(onTouch)
If I helped you out, be sure to click the Accept Answer button below my character! :D