Question says it all, I'm trying to figure out a way;
Basically, I have a door. These doors are all duplicates, they're all the same. However, I don't want to just clone the script to each and every one of them.
Is there a way to use only ONE script for the whole thing?
You could loop over all the doors.
1 | local doorList = { |
2 | game.Workspace.Dor, |
3 | game.Workspace.Dore, |
4 | } |
5 |
6 | for i, door in pairs (doorList) do |
7 | --Do a door thing |
8 | end |
If you don't want to manually put all the doors in the table, you could put them all in autimatically at the start of the game.
1 | local doorList = { } |
2 |
3 |
4 | for i, inst in pairs (game.Workspace:GetDescendants()) do |
5 | if isADoor(inst) then |
6 | --add it to the door list |
7 | end |
8 | end |