How do I add another name onTouched function? I want to add different name on line 6, like skeleton. Thanks!
local debounce = false function onTouched(hit) if not debounce then debounce = true if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " or "Noob" then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25 wait(0.5) debounce = false elseif hit.Parent.Name:sub(1,4) == "Noob" then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25 wait(0.5) debounce = false end end end script.Parent.Touched:connect(onTouched)
Add an elseif.
local debounce = false function onTouched(hit) if not debounce then debounce = true if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then -- I want to add different name here, like skeleton hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25 wait(0.5) debounce = false elseif hit.Parent.Name:sub(1,8) == "Skeleton" then --// Do stuff end end end script.Parent.Touched:connect(onTouched)
There are better ways to go about doing what you're doing, though. Hope this helped.