Advertisement
Guest User

Save de mochila

a guest
Nov 18th, 2019
4,306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. local DataStore = game:GetService("DataStoreService")
  2. local ds = DataStore:GetDataStore("Bag")
  3.  
  4. game.Players.PlayerAdded:Connect(function(player)
  5. local folder = Instance.new("Folder", player)
  6. folder.Name = "Bag"
  7. local value = Instance.new("IntValue", folder)
  8. value.Name = "Amount"
  9. local value2 = Instance.new("IntValue", folder)
  10. value2.Name = "Max"
  11. value2.Value = 20
  12. value.Value = ds:GetAsync(player.UserId)
  13. ds:SetAsync(player.UserId, value.Value)
  14. value.Changed:connect(function()
  15. ds:SetAsync(player.UserId, value.Value, value2.Value)
  16. end)
  17. end)
  18.  
  19. game.Players.PlayerRemoving:Connect(function(player)
  20. ds:SetAsync(player.UserId, player.Bag:WaitForChild("Amount").Value, player.Bag:WaitForChild("Max").Value)
  21. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement