Trying to store PlayerGui.Menu.Stats.Z.Money.Text
localScript position = game.Players.LocalPlayer.PlayerGui.Menu.Stats.Z.Money.LocalScript
local money = script.Parent:WaitForChild("Money") local Gui = script.Parent money.Changed:connect(function() Gui.Text = money.Value end)
ServerScriptService
local dataStore = game:GetService("DataStoreService"):GetDataStore("Money") function SaveData(dataname, playerid, value) dataStore:SetAsync(playerid, value) print(playerid) print(value) end game.Players.PlayerAdded:connect(function(player) local money = player.PlayerGui:WaitForChild("Menu").Stats.Z.Money["Money"] money.Value = dataStore:GetAsync(player.userId) money.Changed:connect(function() SaveData("Money", player.userId, money.Value) wait(1) SaveData("Money", player.userId, money.Value) end) end)
I know RedcommanderV2 answered your question, but I'm here to elaborate.
As I always say when I see messy code, a clean code is key to getting help faster. Your indenting is a little bit messy, but it's not a big deal. When you make a larger script, it could be problematic though.
I would suggest reviewing this article.
Now onto your actual issue
Server's can necessarily see what's inside the player. They acknowledge the existence of the PlayerGui, StarterPack, and Backpack, but they don't actually see what's contained in them.
As a visual example, this is what the client sees. Notice the arrows that show how there are children. This is what the server sees. Notice there are no arrows indicating the existence of children.
As a fix to your solution, I would consider saving the values either in ReplicatedStorage
or ServerStorage
.
Note that ReplicatedStorage is replicated both to the client and server, however, ServerStorage is only shown to the server.