Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStore = game:GetService("DataStoreService"):GetDataStore("Codes")
- game.Players.PlayerAdded:Connect(function(player)
- local key = "codes-"..player.userId
- local folder = Instance.new("Folder", player)
- folder.Name = "Codes"
- local save = DataStore:GetAsync(key)
- if save then
- for i = 1,#save do
- local saved = Instance.new("BoolValue", folder)
- saved.Name = save[i]
- end
- end
- end)
- game.ReplicatedStorage.Code.OnServerEvent:Connect(function(player, reward ,code)
- local key = "codes-"..player.userId
- local currency = player.leaderstats:FindFirstChild("Cash")
- currency.Value = currency.Value + reward
- local bool = Instance.new("BoolValue", player.Codes)
- bool.Name = code
- bool.Value = true
- local activated = {}
- for i,v in pairs(player.Codes:GetChildren()) do
- if v:isA("BoolValue") then
- table.insert(activated, v.Name)
- DataStore:SetAsync(key, activated)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement