Advertisement
maximus4811

Scripting Help

Aug 17th, 2024 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local pointPart1 = game.Workspace.PointsPlaceFolder.PointPart1
  3.  
  4. local function onCharacterAdded(character, player)
  5.     player:SetAttribute("IsAlive", true)
  6.    
  7.     local humanoid = character:WaitForChild("Humanoid")
  8.    
  9.     humanoid.Died:Connect(function()
  10.         local points = player.leaderstats.Points
  11.         points.Value = 0
  12.         player:SetAttribute("IsAlive", false)
  13.     end)
  14. end
  15.  
  16. local function onPlayerAdded(player)
  17.     local leaderstats = Instance.new("Folder")
  18.     leaderstats.Name = "leaderstats"
  19.     leaderstats.Parent = player
  20.    
  21.     local points = Instance.new("IntValue")
  22.     points.Name = "Points"
  23.     points.Value = 0
  24.     points.Parent = leaderstats
  25.    
  26.     player:SetAttribute("IsAlive", false)
  27.    
  28.     player.CharacterAdded:Connect(function(character)
  29.         onCharacterAdded(character, player)
  30.     end)
  31. end
  32.  
  33. Players.PlayerAdded:Connect(onPlayerAdded)
  34.  
  35. while true do
  36.     task.wait(1)
  37.     local playerList = Players:GetPlayers()
  38.     for currentPlayer = 1, #playerList do
  39.         local player = playerList[currentPlayer]
  40.         if player:GetAttribute("IsAlive") then
  41.             local points = player.leaderstats.Points
  42.             if pointPart1.Touched then
  43.                 points.Value = points.Value + 10
  44.             end
  45.         end
  46.     end
  47. end
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement