This successfully prints “test” when one of the values changes.
This, script, however doesn’t work;
I’ve been struggling with this for a while now, just don’t get it.
I even copy & pasted it into a new game, it didn’t work in the new game. Doesn’t make sense?
Could you show some specific instances of changes you make to the tables in which it doesn’t print anything?
PS: You shouldn’t store data with the key as username in the same table as where you keep the methods of the module. What if someone joins with “AddPlayer” as username, or any other name you use as a method? It’d be overridden by PlayerData[PlayerName] = {}, and then you’re in trouble. Use a different table to store the player data, or reference them by the userid / player object.
The issue here could have something to do with nil values not printing properly on their own. A fix to this could be add something else into the print:
print(nil) -->> creates an empty new line
print(nil,"aaaaaa") -->> creates a new line with 'nil aaaaaa'
The metatable is set to PlayerData[PlayerName], not PlayerData[PlayerName].AllStats. Test is not a index of the former, so it won’t fire __newindex when it’s created.
Yep. Even if they weren’t, I’d be changing the values in the same exact way.
Also this probably won’t help, but it worked earlier today. It stopped working on itself randomly. I undone my edits to the code but even the earlier versions that supposedly worked, didn’t work anymore.
@The_PieDude Figured it out. I was supposed to change the values by doing; PlrStats[PlayerName].Snowballs = someValue
Because they’re linked & __index says the data in the whole table is the data in the allstats table.