Eric_W

Gun Button

May 16th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local button = script.Parent
  2. local gun = game.Lighting.AssaultRifle
  3. local cost = 12
  4. local debounce = {}
  5.  
  6. button.Touched:connect(function(part)
  7.     local player = game.Players:GetPlayerFromCharacter(part.Parent)
  8.     if player and not debounce[player] then
  9.         debounce[player] = true
  10.         local stats = player:findFirstChild("leaderstats")
  11.         local currencyHolder = stats and stats:findFirstChild("KOs")
  12.         local currencyValue = currencyHolder and currencyHolder.Value
  13.  
  14.         if currencyValue and currencyValue >= cost then
  15.             gun:clone().Parent = player.Backpack
  16.  
  17.             button.BrickColor = BrickColor.new(1004)
  18.             wait(0.1)                                          
  19.             button.BrickColor = BrickColor.new(1001)
  20.         end
  21.         debounce[player] = nil
  22.     end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment