YourMain12

Leaderboard

Jan 6th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. -- Create a new Leaderstats object
  2. local leaderstats = Instance.new("Folder")
  3. leaderstats.Name = "Leaderstats"
  4. leaderstats.Parent = game:GetService("ServerScriptService")
  5.  
  6. -- Create a new "Points" stat
  7. local points = Instance.new("IntValue")
  8. points.Name = "Points"
  9. points.Parent = leaderstats
  10. points.Value = 0
  11.  
  12. -- Create a function to add points to the stat
  13. function addPoints(player, amount)
  14.     local playerStats = player:FindFirstChild("leaderstats")
  15.     if playerStats then
  16.         local points = playerStats:FindFirstChild("Points")
  17.         if points then
  18.             points.Value = points.Value + amount
  19.         end
  20.     end
  21. end
  22.  
  23. -- Connect the function to a player's "CharacterAdded" event
  24. game.Players.PlayerAdded:Connect(function(player)
  25.     player.CharacterAdded:Connect(function(character)
  26.         addPoints(player, 10)
  27.     end)
  28. end)
  29.  
Tags: lua
Add Comment
Please, Sign In to add comment