Advertisement
HowToRoblox

DonateListScript

Apr 4th, 2020
1,260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local list = script.Parent.PlayerList
  2.  
  3. local amountTextBox = script.Parent.DonateAmount
  4.  
  5. local template = game.ReplicatedStorage.PlayerNameTemplate
  6.  
  7.  
  8. local onDonateEvent = game.ReplicatedStorage.OnDonateClicked
  9.  
  10.  
  11. local cooldown = false
  12.  
  13.  
  14. while wait() do
  15.  
  16.    
  17.     game.Players.PlayerRemoving:Connect(function(plrLeft)
  18.        
  19.         if list:FindFirstChild(plrLeft.Name) then list[plrLeft.Name]:Destroy() end
  20.     end)
  21.  
  22.  
  23.     for i, plr in pairs(game.Players:GetChildren()) do
  24.        
  25.         if not list:FindFirstChild(plr.Name) and plr ~= game.Players.LocalPlayer then
  26.        
  27.        
  28.             local plrName = template:Clone()
  29.             plrName.Text = plr.Name
  30.             plrName.Name = plr.Name
  31.                
  32.             plrName.Parent = list
  33.        
  34.         end
  35.     end
  36.        
  37.        
  38.     for i, plrName in pairs(list:GetChildren()) do
  39.        
  40.        
  41.         if plrName.ClassName == "TextButton" then
  42.            
  43.            
  44.             plrName.MouseButton1Click:Connect(function()
  45.                
  46.                
  47.                 if not cooldown then
  48.                
  49.                     cooldown = true
  50.                    
  51.                    
  52.                     local amount = amountTextBox.Text
  53.                    
  54.                    
  55.                     if amount and tonumber(amount) then
  56.                    
  57.                         onDonateEvent:FireServer(amount, plrName.Text) 
  58.                     end
  59.                    
  60.                    
  61.                     wait(2)
  62.                    
  63.                    
  64.                     cooldown = false
  65.                 end
  66.             end)
  67.         end
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement