Advertisement
Existence_YT

[MakingASimulator] LeaderboardHandler

May 26th, 2020
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local ds2 = require(1936396537)
  2. game.Players.PlayerAdded:Connect(function(plr)
  3.     local leaderstats = Instance.new("Folder", plr)
  4.     local clicks = Instance.new("NumberValue", leaderstats)
  5.     local multiplier = Instance.new("NumberValue", leaderstats)
  6.     leaderstats.Name = "leaderstats"
  7.     clicks.Name = "Clicks"
  8.     multiplier.Name = "Multiplier"
  9.     multiplier.Value = 0
  10.     clicks.Changed:Connect(function()
  11.         local UI = plr:WaitForChild("PlayerGui"):WaitForChild("HUD"):WaitForChild("StatsFrame")
  12.         UI.ClicksFrame.F1.Val.Text = tostring(clicks.Value)
  13.     end)
  14.     multiplier.Changed:Connect(function()
  15.         local UI = plr:WaitForChild("PlayerGui"):WaitForChild("HUD"):WaitForChild("StatsFrame")
  16.         UI.MultiplierFrame.F1.Val.Text = tostring(multiplier.Value).."x"
  17.     end)
  18.     local clicks = ds2("clicks", plr)
  19.     local multiplier = ds2("multiplier", plr)
  20.     local function update(ds, val)
  21.         if ds == "clicks" then
  22.             plr:WaitForChild("leaderstats"):WaitForChild("Clicks").Value = val
  23.         elseif ds == "multiplier" then
  24.             plr:WaitForChild("leaderstats"):WaitForChild("Multiplier").Value = val
  25.         end
  26.     end
  27.     ds2.Combine("stats", "clicks", "multiplier")
  28.     update("clicks", clicks:Get(0))
  29.     update("multiplier", multiplier:Get(0))
  30.     clicks:OnUpdate(function(newVal)
  31.         update("clicks", newVal)
  32.     end)
  33.     multiplier:OnUpdate(function(newVal)
  34.         update("multiplier", newVal)
  35.     end)
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement