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

How can I use an event on more than 1 thing at once?

Okay, so I have a melee tool that has 2 blades. Im making it damage by using this.... tool.Touched:connect(function() "This is where I put the damaging code" end)

BUT I need it to pretty much be an event that says "If either of these parts is touched..." take damage from either blade.

How would I write it like that, without writing the same function twice?

2 comments

0

just fire the event if the part has been touched, if u access the part from outside of it like their parent or so then u can use the same name for them both and say if its been touched then fire the event that damages

0

maybe you can combine these parts in a union and try it that way

1 answer

an example to my comment would be

game.Workspace:GetChildren("Part").Touched:Connect(function()

end)

and i got 2 part in workspace called Part

3 comments

0

That does not work. GetChildren() has no parameter.

1

To get each instance of the Part class, you would have to run a for loop through the table and check for each part.

0

And how do I do that?

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