Advertisement
Aquarius_Raverus

E

Aug 26th, 2020
1,476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. -- Drop System
  2.  
  3. -- Variables
  4.  
  5. local Storage = game:GetService("ReplicatedStorage")
  6. local Players = game:GetService("Players")
  7.  
  8. local Events = Storage:WaitForChild('SenEvents')
  9.  
  10. local Drop = Events.Drop
  11.  
  12. local DropCooldowns = {};
  13.  
  14. -- Functions
  15.  
  16. Players.PlayerAdded:Connect(function(plr)
  17.    
  18.     local L = Instance.new("Folder", plr)
  19.     L.Name = 'leaderstats'
  20.    
  21.     local Yen = Instance.new("IntValue", L)
  22.     Yen.Name = 'Yen'
  23.     Yen.Value = 100
  24.    
  25. end)
  26.  
  27. local function checkCooldown(plr)
  28.     if DropCooldowns[plr.UserId] then
  29.         return false
  30.     elseif not DropCooldowns[plr.UserId] then
  31.         return true
  32.     end
  33. end
  34.  
  35. Drop.OnServerEvent:Connect(function(plr, action, array)
  36.     if not array then plr:Kick('Stop exploiting. If you believe this to be false, DM Senko#6478') return end
  37.     if not action then plr:Kick('Stop exploiting. If you believe this to be false, DM Senko#6478') return end
  38.    
  39.     if action == 'Drop' then
  40.        
  41.         if array['GiveTo'] then
  42.             local to = array['GiveTo']
  43.            
  44.             local obj = array['Object']
  45.            
  46.             game.Workspace.MoneyDrops[obj.Name]:Destroy()
  47.            
  48.             warn(to, to.Name)
  49.            
  50.             to.leaderstats.Yen.Value = to.leaderstats.Yen.Value + array['Amount']
  51.            
  52.            
  53.             return
  54.         end
  55.        
  56.         local amount = array['Amount']
  57.        
  58.         local CurrentYen = plr.leaderstats.Yen
  59.         if not CurrentYen then Drop:FireClient(plr, 'Error', 'There was an error when trying to drop your yen.') return end
  60.            
  61.         if CurrentYen.Value < amount then Drop:FireClient(plr, 'Error', 'Please select a valid amount of yen.') return end
  62.        
  63.         if DropCooldowns[plr.UserId] then Drop:FireClient(plr, 'Error', 'Please wait two seconds before dropping yen again.') return end
  64.        
  65.                
  66.         for name,v in pairs(array) do
  67.            
  68.             if name == "CanDrop" then
  69.                 plr:Kick('Stop exploiting. If you believe this to be false, DM Senko#6478')
  70.                 return;
  71.             end
  72.         end
  73.        
  74.         array['CanDrop'] = checkCooldown(plr)
  75.        
  76.         if array['CanDrop'] == true then
  77.             print'can drop'
  78.             DropCooldowns[plr.UserId] = true
  79.            
  80.             --// Drop actions.
  81.            
  82.            
  83.             CurrentYen.Value = CurrentYen.Value - amount
  84.            
  85.             Drop:FireClient(plr, 'Notif', 'Successfully dropped: '.. amount.. ' Yen')
  86.            
  87.             -- Cloning
  88.            
  89.             local Clone = script:WaitForChild("Part"):Clone()
  90.             Clone.Main.TextLabel.Text = amount
  91.             Clone.Parent = workspace.MoneyDrops
  92.            
  93.             Clone.CFrame = plr.Character.PrimaryPart.CFrame * CFrame.new(0,0,-2)
  94.            
  95.             Clone.CanCollide = false
  96.            
  97.             Drop:FireAllClients('Drop',Clone)
  98.            
  99.             wait(2)
  100.            
  101.             DropCooldowns[plr.UserId] = nil
  102.            
  103.         end
  104.    
  105.        
  106.     end
  107. end)
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement