I'll make this short, so I am trying to make a currency save system, but it won't work. So If I change "lvl" to 5, next time when I join the game it'll say "0", that means that I have no currency, obviously, no output errors as far as I can see.
local players = game:GetService("Players") local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CashValueSaver") players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder") folder.Name = "leaderstats" folder.Parent = player local currency1 = Instance.new("IntValue") currency1.Name = "lvl" currency1.Parent = player.leaderstats currency1.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId, currency1.Value) currency1.Changed:connect(function() ds1:SetAsync(player.UserId, currency1.Value) end) end)
try watching this video https://www.youtube.com/watch?v=5AUP9C0rtBY
CashStore = game:GetService("DataStoreService"):GetDataStore("DataStore") function PlayerEntered(player) repeat wait() until player.Character local stats = Instance.new("IntValue") stats.Parent = player stats.Name = "leaderstats" local cash = Instance.new("IntValue") cash.Parent = stats cash.Name = "Cash" if CashStore:GetAsync("Points_"..player.Name) ~= nil then cash.Value = CashStore:GetAsync("Points_"..player.Name) else cash.Value = 500 end cash.Changed:connect(function(Val) CashStore:SetAsync("Points_"..player.Name, Val) end) end game.Players.PlayerAdded:connect(PlayerEntered)
I just wrote a script using the devfourm