Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. local ds = game:GetService("DataStoreService"):GetDataStore("-tCodes01")
  2.  
  3. game.Players.PlayerAdded:Connect(function(player)
  4. local key = "codes-"..player.userId
  5. local folder = Instance.new("Folder",player)
  6. folder.Name = "Codes"
  7. local save = ds:GetAsync(key)
  8. if save then
  9. for i = 1,#save do
  10. local temp = Instance.new("BoolValue",folder)
  11. temp.Name = save[i]
  12. end
  13. end
  14. end)
  15.  
  16. game.ReplicatedStorage.EnterCode.OnServerEvent:Connect(function(player,reward,code)
  17. local key = "codes-"..player.userId
  18. local currency = player.leaderstats:FindFirstChild("Cash") -- Name of your currency
  19. currency.Value = currency.Value + reward
  20.  
  21. local bool = Instance.new("BoolValue",player.Codes)
  22. bool.Name = code
  23. bool.Value = true
  24.  
  25. local activated = {}
  26. for i,v in pairs(player.Codes:GetChildren()) do
  27. if v:isA("BoolValue") then
  28. table.insert(activated, v.Name)
  29. ds:SetAsync(key,activated)
  30. end
  31. end
  32. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement