Aquarius_Raverus

Yesir

Aug 26th, 2020
1,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. -- Was lazy srry
  2.  
  3. local p = game:GetService("Players")
  4. local cooldowns = {};
  5.  
  6. local function getDist(a,b)
  7.     local aPrim = a.PrimaryPart
  8.     local bPrim = b.PrimaryPart
  9.    
  10.     local dist = (aPrim.Position - bPrim.Position).magnitude
  11.     warn(dist)
  12.    
  13.     return dist
  14. end
  15.  
  16. p.PlayerAdded:Connect(function(plr)
  17.     local l = Instance.new("Folder", plr)
  18.     l.Name = 'leaderstats'
  19.    
  20.     local yen = Instance.new("IntValue", l)
  21.     yen.Name = 'Yen'
  22.     yen.Value = 100
  23.    
  24.     plr.Chatted:Connect(function(msg)
  25.        
  26.         local args = msg:split(" ")
  27.        
  28.         local command = args[1]
  29.         command = command:lower()
  30.        
  31.         warn(command)
  32.        
  33.         if command == '!givemoney' then
  34.             if cooldowns[plr.UserId] then return end
  35.            
  36.             cooldowns[plr.UserId] = true
  37.            
  38.             local target = args[2]
  39.            
  40.             --// case sensitive srry
  41.            
  42.             if game.Players:FindFirstChild(target) then
  43.                
  44.                 local amount = args[3]
  45.                
  46.                 if not amount then return end
  47.                
  48.                 amount = tonumber(amount)
  49.                
  50.                 -- giving money
  51.                
  52.                 local toGive = game.Players[target]
  53.                 if not toGive then return end
  54.                
  55.                 if plr.leaderstats.Yen.Value < amount then return end
  56.                
  57.                 -- getting distance
  58.                
  59.                 local wspPlr = workspace:WaitForChild(plr.Name)
  60.                 local otherPlr = workspace:WaitForChild(toGive.Name)
  61.                
  62.                 if getDist(wspPlr, otherPlr) <= 10 then
  63.                     plr.leaderstats.Yen.Value = plr.leaderstats.Yen.Value - amount
  64.                    
  65.                     toGive.leaderstats.Yen.Value = toGive.leaderstats.Yen.Value + amount
  66.                    
  67.                     coroutine.wrap(function()
  68.                         wait(2)
  69.                        
  70.                         cooldowns[plr.UserId] = nil
  71.                     end)()
  72.                 end
  73.                
  74.             else
  75.                 print'not found'
  76.             end
  77.            
  78.            
  79.         end
  80.        
  81.     end)
  82.    
  83. end)
Advertisement
Add Comment
Please, Sign In to add comment