Advertisement
Guest User

Roblox Code Script

a guest
May 3rd, 2019
1,293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local ds = game:GetService("DataStoreService"):GetDataStore("-tCodes01")
  2.  
  3.  
  4.  
  5. game.Players.PlayerAdded:Connect(function(player)
  6.  
  7.     local key = "codes-"..player.userId
  8.  
  9.     local folder = Instance.new("Folder",player)
  10.  
  11.     folder.Name = "Codes"
  12.  
  13.     local save = ds:GetAsync(key)
  14.  
  15.     if save then
  16.  
  17.         for i = 1,#save do
  18.  
  19.             local temp = Instance.new("BoolValue",folder)
  20.  
  21.             temp.Name = save[i]
  22.  
  23.         end
  24.  
  25.     end
  26.  
  27. end)
  28.  
  29.  
  30.  
  31. game.ReplicatedStorage.EnterCode.OnServerEvent:Connect(function(player,reward,code)
  32.  
  33.     local key = "codes-"..player.userId
  34.  
  35.     local currency = player.leaderstats:FindFirstChild("Cash") -- Name of your currency
  36.  
  37.     currency.Value = currency.Value + reward
  38.  
  39.    
  40.  
  41.     local bool = Instance.new("BoolValue",player.Codes)
  42.  
  43.     bool.Name = code
  44.  
  45.     bool.Value = true
  46.  
  47.    
  48.  
  49.     local activated = {}
  50.  
  51.     for i,v in pairs(player.Codes:GetChildren()) do
  52.  
  53.         if v:isA("BoolValue") then
  54.  
  55.             table.insert(activated, v.Name)
  56.  
  57.             ds:SetAsync(key,activated)
  58.  
  59.         end
  60.  
  61.     end
  62.  
  63. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement