Hi, so I have a game where each level is a different place and when you complete a level, you get a certain amount of coins. I want to know how to have the same amount of Coins throughout each of the levels so I can do this. I have been looking at DataStores but it is quite confusing. Please help.
Coins Leaderboard script (with AutoSave):
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CoinSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Coins = Instance.new("IntValue",leader)
Coins.Name = "Coins"
Coins.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Coins.Value)
Coins.Changed:connect(function()
ds:SetAsync(player.UserId, Coins.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Coins.Value)
end)

2 comments
Oh thx very much
Your welcome