local datastore = game:GetService("DataStoreService"):GetDataStore("MyRPGDataStore") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue") leaderstats.Name = "leaderstats" leaderstats.Parent = player local xd = Instance.new("IntConstrainedValue") xd.Name = "Level" xd.Parent = leaderstats xd.Value = 1 xd.MaxValue = workspace:FindFirstChild("GameSettings").MaxLevel.Value xd.MinValue = 0 local qe = Instance.new("IntConstrainedValue") qe.Name = "EXP" qe.Parent = leaderstats qe.Value = 0 xd.MaxValue = workspace:FindFirstChild("GameSettings").MaxEXP.Value xd.MinValue = 0 local ss = Instance.new("IntConstrainedValue") ss.Name = "Gold" ss.Parent = leaderstats ss.Value = 0 xd.MaxValue = workspace:FindFirstChild("GameSettings").MaxGold.Value xd.MinValue = 0 local key = "user-" .. player.userId local storeditems = datastore:GetAsync(key) if storeditems then xd.Value = storeditems[1] qe.Value = storeditems[2] ss.Value = storeditems[3] else local items = {xd.Value, qe.Value, ss.Value} datastore:SetAsync(key, items) end while wait(120) do local stats = player:FindFirstChild("leaderstats") local aitems = {stats.Level.Value, stats.EXP.Value, stats.Gold.Value} local key = "user-" .. player.userId datastore:SetAsync(key, aitems) end end) game.Players.PlayerRemoving:connect(function(player) local stats = player:FindFirstChild("leaderstats") local items = {stats.Level.Value, stats.EXP.Value, stats.Gold.Value} local key = "user-" .. player.userId datastore:SetAsync(key, items) end)
Gold part is Line 23 to Line 28.
I see the errors on Line 27 and 28
"xd.MaxValue = workspace:FindFirstChild("GameSettings").MaxGold.Value"
and
"xd.MinValue = 0"
xd is a local of Level is xd (See on Line 9) -
local xd = Instance.new("IntConstrainedValue")
The local of Gold is ss (See on Line 23) -
local ss = Instance.new("IntConstrainedValue")
You need to change the local value of Level to local value of Gold on Line 27 and 28
xd.MaxValue = workspace:FindFirstChild("GameSettings").MaxGold.Value xd.MinValue = 0
To
ss.MaxValue = workspace:FindFirstChild("GameSettings").MaxGold.Value ss.MinValue = 0
Don't forget upvote me :)