How do I use a script on multiple different nodes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mr. Gamezz

I was watching an inventory system tutorial but came across a problem. I needed the slot to switch to a different style if there was an item in the panel (slot). Since the script was on every panel (slot), It ran all of them at the same time, resulting in all of them having the same style. How would I make them independent yet have the same script?

:bust_in_silhouette: Reply From: spaceyjase

A naive approach could be to have an export variable that simply toggles a different style that you can change in the editor. Create different scenes for different inventory types with the configuration you desire or alternatively, have a base class and implement specialised inventories (or just write a different script).

Note that each instance of a script is independent of other instances; e.g. each panel you create will run its own _process and have its own variables - they aren’t the same script.

Ok! Thank you! :slight_smile: I think I figured it out now.

Mr. Gamezz | 2021-11-17 03:57