Hey guys, wanted to get some tips on user data management. I’ve got a module script called PlayerManager that manages player data. It accesses the datastore and stores all the player’s table within a table called PlayerData.
To keep my functions more streamlined, I’ve created another module script called CoinManager, that specifically alters the Player’s coin data. The script hierarchy is as such:
My coin manager will access the player manager’s table and modify it like this:
local CoinManager = {}
local PlayerManager = require(script.Parent)
function setCoins(playerId)
PlayerManager.PlayerData[playerId]["Coins"] = 10
end
---Many other functions---
---...
return CoinManager
What are some pros and cons to accessing and manipulating another scripts table? Are there some best practices?