How do I fix the leaderstats duplicated in value?

Can someone please help we with the code I currently have. I currently have a code for two leaderstats, cash & points. The points leaderstats main script is apart of an ordering system and the cash leaderstat is added on to that script. In game they both show up both show up but the stats are exactly identical everytime I join the game.
Code:
Script

Leaderstat:
Leaderstat

image

You are accessing the same Data Store for both stats.

P.S: Try using one single data store and put the data in a table, its way easier :smiley:

1 Like

How would I go about making both the savedpoints and savedcash use the same data store?

You can just use a table! Here’s an example below:

-- use this when you want to save data
local PointsValue = -- the point object value
local CashValue = -- the cash object value

local Data = {
       Points = PointsValue.Value,
       Cash = CashValue.Value
     }

-- make sure to use a pcall for handling data, as it may error some times and cause data loss due to roblox going down

local success, message = pcall(function(
      DataStore:SetAsync(player.UserId, Data)
end)

if not success then
   -- do whatever you want to happen whenever the data fails to save
end
1 Like