local gold = game.Workspace.Userdata[player.Name.."_Data"].Inventory.Gold
gold.Changed:Connect(function()
script.Parent.Text = gold.Value
end)
So this the current way that I do the .Change when the gold is updated but if there was multiple values being update like gold, maybe diamonds or levels would I just use this script on everything that needs changing when a value is changed or could this be managed in one script maybe?
It really depends on how you handle player datas. Some developers used tables to save and change data when the player is in the server. Do note that if there is like 3 InstanceValue in a 30 player, that may cause some strain in the server (no evidence, but a guess)
That would impact performance when there are a lot of players. I would recommend using tables. As well, you do not need to JSONEncode tables while saving to DataStores.
Would a ModuleScript work? You can define a function in one:
modulescript. in ServerStorage
local module = {}
local example = function(callingScript, value)
value.Changed:Connect(function()
callingScript.Parent.Text = value.Value
end)
end
return module
In a normal script:
local modulescript = require(game.ServerStorage.ModuleScript)
modulescript.example(script, gold)