Advertisement
MandB

Clicking game!

Apr 23rd, 2022
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. --Click Count script
  2.  
  3. while wait() do
  4.     local player = game.Players.LocalPlayer
  5.     script.Parent.Text = "Clicks: "..player:WaitForChild("leaderstats"):FindFirstChild("Clicks").Value
  6. end
  7.  
  8. --detector script
  9.  
  10. local ClicksButton = script.Parent
  11. local replicatedStorage = game:GetService("ReplicatedStorage")
  12. local RemoteEvents = replicatedStorage:WaitForChild("RemoteEvents")
  13. local clickEvents = RemoteEvents:WaitForChild("click")
  14.  
  15. local Players = game:GetService("Players")
  16. local player = Players.LocalPlayer
  17.  
  18. function debounce(func)
  19.     local inRunning = false
  20.     return function()
  21.         if not isRunning then
  22.             isRunning = true
  23.             wait(0.05)
  24.             func()
  25.             isRunning = false
  26.         end
  27.     end
  28. end
  29.  
  30. ClicksButton.MouseButton1Click:Connect(function()
  31.     clickEvents:FireServer(player)
  32. end)
  33.  
  34. --Click script
  35.  
  36. local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
  37. local button = script.Parent
  38.  
  39. button.MouseButton1Click:Connect(function()
  40. game.Workspace.GetClickScript.GetClick:FireServer()
  41. end)
  42.  
  43. --leaderstats
  44.  
  45. game.Players.PlayerAdded:Connect(function(plr)
  46.     local leaderstats = Instance.new("Folder", plr)
  47.     leaderstats.Name = "leaderstats"
  48.    
  49.     local Clicks = Instance.new("IntValue", leaderstats)
  50.     Clicks.Name = "Clicks"
  51. end)
  52.  
  53. --script in workspace
  54.  
  55. script.GetClick.OnServerEvent:Connect(function(plr)
  56.     local leaderstats = plr:WaitForChild("leaderstats")
  57.     leaderstats.Clicks.Value = leaderstats.Clicks.Value + 1
  58. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement