I wanne save the Robux value, but I don't know how to save a value if its inside an ReplicatedStorage. I tried this but then I get follow errors: Argument 1 missing or nil Script 'ServerScriptService.LinkedLeaderboard', Line 79
game.ServerScriptService:WaitForChild("PlayerDataStore")
local PDSM = require(game.ServerScriptService.PlayerDataStore)
function Save(Player,SaveName,Value)
local Data = PDSM:GetSaveData(Player)
Data:Set(SaveName,Value)
end
function Load(Player,SaveName)
local Data = PDSM:GetSaveData(Player)
local Number = Data:Get(SaveName)
if SaveName == "Date" then
return (Number or 1)
else
return (Number or 0)
end
end
function CoinsChange(PlayerIns,Stat)
Save(game.ReplicatedStorage.LostStorage:FindFirstChild(PlayerIns.Name.Value)) -- Find the data and save it
end
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local GoldTix = Instance.new("IntValue")
GoldTix.Name = "GoldTix"
GoldTix.Value = 0
local Gold = Instance.new("IntValue")
Gold.Name = "Gold"
Gold.Value = 0
local Tix= Instance.new("IntValue")
Tix.Name = "Tix"
Tix.Value = 0
local Robux= Instance.new("IntValue")
Robux.Name = "Robux"
Robux.Value = 0
local cashmoney = game.ReplicatedStorage.MoneyStorage:FindFirstChild(newPlayer.Name)
if cashmoney ~= nil then
cashmoney.Changed:connect(function()
Tix.Value = cashmoney.Value
end)
end
local TixGold = game.ReplicatedStorage.GoldTixStorage:FindFirstChild(newPlayer.Name)
if TixGold ~= nil then
TixGold.Changed:connect(function()
GoldTix.Value = TixGold.Value
end)
end
local Golds = game.ReplicatedStorage.GoldStorage:FindFirstChild(newPlayer.Name)
if Golds ~= nil then
Golds.Changed:connect(function()
Gold.Value = Golds.Value
end)
end
local GoldsAA = game.ReplicatedStorage.LostStorage:FindFirstChild(newPlayer.Name)
if GoldsAA ~= nil then
GoldsAA.Changed:connect(function()
Robux.Value = GoldsAA.Value
end)
end
GoldTix.Parent = stats
Gold.Parent = stats
Tix.Parent = stats
Robux.Parent = stats
Robux.Changed:connect(function() CoinsChange(game.ReplicatedStorage.LostStorage:FindFirstChild(newPlayer.Name.Value)) end) -- Load
Robux.Value = Load(game.ReplicatedStorage.LostStorage:FindFirstChild(newPlayer.Name.Value)) -- Load
while true do
if newPlayer.Character ~= nil then break end
wait(5)
end
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
The robux only will be ghost money what I mean their prevous money saves but when they join back they cannot use it because the money is at "ReplicatedStorage"
Does anyone know how to fix this? Thanks!

8 comments
What do you mean "Ghost Money"? What exactly isn't happening that you want to happen?
You used the their, when you should have used there. They're easy to mix up, as for your question, well I only read the title and first sentence, then came here to post this comment.
It only saves the stats, when I want it saves the value inside the ReplicatedStorage.
I'm not sure what you're trying to ask here.
Did edit the question
he is trying to get the saved value within the datastore.
You need to use two arguments. You only have 1 on line 79.
How to do two?