Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStore = game:GetService("DataStoreService")
- local ds = DataStore:GetDataStore("Bag")
- game.Players.PlayerAdded:Connect(function(player)
- local folder = Instance.new("Folder", player)
- folder.Name = "Bag"
- local value = Instance.new("IntValue", folder)
- value.Name = "Amount"
- local value2 = Instance.new("IntValue", folder)
- value2.Name = "Max"
- value2.Value = 20
- value.Value = ds:GetAsync(player.UserId)
- ds:SetAsync(player.UserId, value.Value)
- value.Changed:connect(function()
- ds:SetAsync(player.UserId, value.Value, value2.Value)
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- ds:SetAsync(player.UserId, player.Bag:WaitForChild("Amount").Value, player.Bag:WaitForChild("Max").Value)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement