Advertisement
Sungmingamerpro13

Wins and Plays Leaderstats Lobby

Jun 18th, 2023
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.36 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local SaveCurrency = game:GetService("DataStoreService"):GetDataStore("Wins")
  3. local SaveCurrency2 = game:GetService("DataStoreService"):GetDataStore("Plays")
  4.  
  5. game.Players.PlayerAdded:Connect(function(player)
  6.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
  7.         local Folder = Instance.new("Folder",player)
  8.         Folder.Name = "leaderstats"
  9.  
  10.         local Currency = Instance.new("NumberValue",Folder)
  11.         Currency.Name = game.ReplicatedStorage.Tags.WinsValue.Value
  12.         Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
  13.  
  14.         local Currency2 = Instance.new("NumberValue",Folder)
  15.         Currency2.Name = game.ReplicatedStorage.Tags.PlaysValue.Value
  16.         Currency2.Value = SaveCurrency2:GetAsync(player.UserId) or 0
  17.  
  18.     end
  19. end)
  20.  
  21. game.Players.PlayerRemoving:Connect(function(player)
  22.     if game.ReplicatedStorage.Tags.Leaderstats.Value == true then  
  23.         SaveCurrency:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.WinsValue.Value].Value)
  24.         SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.PlaysValue.Value].Value)
  25.     end
  26. end)
  27.  
  28. local teleportData = TeleportService:GetLocalPlayerTeleportData()
  29.  
  30. if teleportData then
  31.     local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
  32.     Player.leaderstats.Wins.Value = Player.leaderstats.Wins.Value + 1
  33. end
  34.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement