Pros and cons on using other module scripts to manage Player Data

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:

image

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?

1 Like