How do I make it so that any part inside a folder does the exact same thing when touched.
For example, if one specific part inside a folder was touched I would use:
folder.part.Touched:Connect( function(touch) if touch.Parent:FindFirstChild("Humanoid") then print("part touched") Humanoid.Health = 0 wait(1) end end )
But then I would have to rewrite this for every single part inside the folder, right?
So how would I avoid this?
Here is code
function killing(touch) if touch.Parent:FindFirstChild("Humanoid") then print("part touched") Humanoid.Health = 0 wait(1) end end for _, s in pairs(folder:GetChildren()) do s.Touched:Connect(killing) end
I tested it, it having errors in console but this working good. P.S.: If you want avoid errors use pcall