#"Generic script" instead of duplicating

12 messages · Page 1 of 1 (latest)

runic lake
#

Hi guys. I made a script that works for what I want. Its a simple script that when I press a button opens a door. There is some variables that are usefull to change the behaviour. Also, I want to have several doors and several buttons in my game.
I don't want to duplicate everytime the script cuz what If I change it somewhere? Its not gonna apply all the changes on all the models. Can I have a general script that is linked to several objects and if I modify my "generic" script, it is modified for all objects?

Thanks for your time guys, I started two days ago so I'm pretty bad at it.

jagged plover
runic lake
#

Yeaah, I think I'm good of this one? Maybe I wasn't clear on my question
How can I make that I don't have to duplicate this script everywhere ?

Cuz right now, whats triggering me is that, If I duplicate my door, its going to have a script in the Button. But the other door also! So If I change one, it doesn't change the other which is weird pretty much. Are you familiar with Unity? I'm searching for something that is like a Monobehaviour pretty much

runic lake
#

If you have multiple doors and buttons in a game, whats best: Duplicating them and the scripts or use a module script? In the documentation, its written that module scripts should be used for managers or stuff like that but I feel like I need a module script ^^

loud pasture
#

CollectionService

#

Tag all buttons and use for _, button in pairs(CollectionService:GetTaggged("TagName")) do

runic lake
#

I went for Module scripts because I feel like I could try different type of buttons (Enable/Disable colliders with a delay or not, etc.). I don't really like doing the same thing for all tags, maybe I will get to it at a certain point 😄
Does my solution looks like a good idea?

slow crane
#

you can do just different tags but its good the module, module is very good

worldly zodiac
#

it's also much faster that way

runic lake
#

fuk