Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DS = game:GetService("DataStoreService")
- local CoinSave = DS:GetDataStore("CoinSave")
- game.Players.PlayerAdded:Connect(function(Player)
- local Folder = Instance.new("Folder")
- Folder.Name = "leaderstats"
- Folder.Parent = Player
- local PetInv = Instance.new("Folder")
- PetInv.Name = "Pets"
- PetInv.Parent = Player
- local Coins = Instance.new("IntValue")
- Coins.Name = "Coins"
- Coins.Value = CoinSave:GetAsync(Player.UserId) or 100000
- Coins.Parent = Folder
- Coins.Changed:Connect(function()
- CoinSave:SetAsync(Player.UserId,Coins.Value)
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(Player)
- CoinSave:SetAsync(Player.UserId,Player.leaderstats("Coins").Value)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement