Okay, so I have two scripts. One basic script in the workplace that makes a "Cash" value for players that is stored in the data store, and another basic script in a TextBox that is supposed to display a players cash value for them. The work space code looks like this:
local DataStoreService = game:GetService("DataStoreService")
game.Players.PlayerAdded:connect(
function(Player)
local PlayerStore = DataStoreService:GetDataStore(tostring(Player.userId), "PlayerData")
end
)
local StatisticsStorage = DataStoreService:GetDataStore("Statistics", "ServerData")
local CashValue = StatisticsStorage:GetAsync("Cash")
print(CashValue)
StatisticsStorage:SetAsync("Cash", 500)
And the script in the TextBox looks like this:
local display = script.Parent
local text = display.Text
local DataStoreService = game:GetService("DataStoreService")
game.Players.PlayerAdded:connect(
function(Player)
local PlayerStore = DataStoreService:GetDataStore(tostring(Player.userId), "PlayerData")
end
)
local StatisticsStorage = DataStoreService:GetDataStore("Statistics", "ServerData")
StatisticsStorage:OnUpdate("Cash",
function(NewValue)
text = "Cash: "..NewValue..
print("Cash value has changed! The new value is: "..NewValue)
end
)
Am I doing something wrong? Assistance is greatly appreciated. Thanks!
Also, the TextBox is in a GUI in the Starter GUI. The text doesnt display at all.

8 comments
Thanks for the help! This really explains a lot. However just one question, What is replicated storage?
ReplicatedStorage is basically what most users used Lighting for before. The ReplicatedStorage is where we put objects in which we want to replicate to clients, for example their cash values. You could also have used the Player instance itself for this or Lighting, but sticking with ReplicatedStorage is "cleaner". Yet, I must admit, putting it inside the Player in this case would be easier as it w
Ohh ok. So basically its like storing a model in the lighting to clone, but easier right? I gotcha. Coolio, but one more thing- I am not using any local scripts, should I be?
I suggest using a local script for the second. If you use server scripts for GUIs, you will notice lag - which you don't want. This script is compatible to be local. And yeah, ReplicatedStorage is just like Lighting, but now it's real purpose is to store things - Lighting was not really intended for this, but everyone used it. ReplicatedStorage is the "official" lighting now.
Btw I noticed an error in your script, you put ,, instead of ..! Just pointing that out. :)
Where exactly? I can't seem to find it... (line number?)
10
A .. was needed instead of a ,, . ,, I dont think can be used in lua.