How to store values that can be used by multiple scripts

basically i need a system to share a value that will be used by multiple scripts to count how fast will be certain stuff spawning. _G for some reason is readonly, game.Tags is actually for… tags y’know and uh int/number/string values dont exist.

self.attr. Everything added to an instance’s attribute will be shared across all scripts, both local and server-sided. Make an instance that is “the counter” and then add “the counter” instance as an instance handle for the rest of your scripts

i thought attributes were unfinished, also crazy how you like have insane script knowledge but like 0 games made

Making attributes through the editor is broken, but you can use attributes just fine via scripting. All you have to do is something along the lines of self.attr.Counter = 0 and it’ll show up. Just know that attributes don’t accept any ol’ value (for instance it can’t take in tables/arrays) so its not a perfect replacement for _G (though it’ll work in 99% of cases)

I’m busy, ok :sob:. The goal was to make a game but other projects (coding Luduvo LSP + starting work on a video tutorial series teaching scripting) alongside life makes it hard to sit down and make a game that isn’t something I can put together in a couple hours. Not to mention that I literally can’t art if my life depended on it so any games developed solely by me will be crap…

1 Like