Advertisement
HowToRoblox

KOTHHandler

May 14th, 2020
3,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local hill = script.Parent:WaitForChild("Hill")
  2. local hitbox = script.Parent:WaitForChild("HillHitbox")
  3.  
  4. local plrsOnHill = {}
  5.  
  6. while wait(10) do
  7.    
  8.     for secsInGame = 30, 0, -1 do
  9.        
  10.         hitbox.Touched:Connect(function(touch) 
  11.             local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
  12.             if plr and not plrsOnHill[plr] then    
  13.                 table.insert(plrsOnHill, plr)
  14.             end
  15.         end)
  16.        
  17.         hitbox.TouchEnded:Connect(function(touch)
  18.             local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
  19.             if plr and plrsOnHill[plr] then
  20.                 table.remove(plrsOnHill, plrsOnHill[plr])
  21.             end
  22.         end)
  23.            
  24.         for i, plrOnHill in pairs(plrsOnHill) do
  25.            
  26.             if not plrOnHill:FindFirstChild("HillPoints") then
  27.                
  28.                 local hillPoints = Instance.new("IntValue")
  29.                 hillPoints.Name = "HillPoints"
  30.                
  31.                 hillPoints.Parent = plrOnHill
  32.                
  33.             end
  34.             plrOnHill.HillPoints.Value = plrOnHill.HillPoints.Value + 1
  35.            
  36.         end
  37.         wait(1)
  38.     end
  39.    
  40.     local winner   
  41.     for i, plr in pairs(game.Players:GetPlayers()) do
  42.        
  43.         if plr:FindFirstChild("HillPoints") then
  44.            
  45.            
  46.             if not winner then winner = plr end
  47.            
  48.             if plr.HillPoints.Value > winner.HillPoints.Value then winner = plr end
  49.         end
  50.     end
  51.     for i, plr in pairs(game.Players:GetPlayers()) do
  52.        
  53.         if plr:FindFirstChild("HillPoints") then plr.HillPoints:Destroy() end
  54.     end
  55.     print(winner.Name .. " wins!")
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement