OOFBOI574

Point System Script (Roblox)

Nov 30th, 2021 (edited)
1,028
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Put in ServerScriptService
  2. local Players = game:GetService("Players")
  3.  
  4. --Line 12-8 is losing points when you die
  5. local function onCharacterAdded(character, player)
  6.     player:SetAttribute("IsAlive", true)
  7.     local humanoid = character:WaitForChild("Humanoid")
  8.     --[[humanoid.Died:Connect(function()
  9.         local points = player.leaderstats.Points
  10.         points.Value = 0
  11.         player:SetAttribute("IsAlive", false)
  12.     end)--]]
  13. end
  14.  
  15. local function onPlayerAdded(player)
  16.     local leaderstats = Instance.new("Folder")
  17.     leaderstats.Name = "leaderstats"
  18.     leaderstats.Parent = player
  19.  
  20.     local points = Instance.new("IntValue")
  21.     points.Name = "Points"
  22.     points.Value = 0
  23.     points.Parent = leaderstats
  24.  
  25.     player:SetAttribute("IsAlive", false)
  26.  
  27.     player.CharacterAdded:Connect(function(character)
  28.         onCharacterAdded(character, player)
  29.     end)
  30. end
  31.  
  32. Players.PlayerAdded:Connect(onPlayerAdded)
  33.  
  34. while true do
  35.     wait(1)
  36.     local playerList = Players:GetPlayers()
  37.     for i = 1, #playerList  do
  38.         local player = playerList[i]
  39.         if player:GetAttribute("IsAlive") then
  40.             local points = player.leaderstats.Points
  41.             points.Value = points.Value + 1
  42.         end
  43.     end
  44. end
RAW Paste Data