Advertisement
qsenko1

GearProblem #1

Apr 29th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.61 KB | None | 0 0
  1. game.ReplicatedStorage.Accessories.Events.GiveAccessory1.OnServerInvoke = function(player, GobletName)
  2.     if debounce == true then
  3.         debounce = false
  4.         --print("RemoteFunction fired")
  5.         local GobletifsInInventory ;
  6.  
  7.         if player.Backpack:FindFirstChild("Goblet") then
  8.             GobletifsInInventory = true
  9.         end    
  10.  
  11.         if Goblet then
  12.             if Goblet:FindFirstChild("Price") then
  13.                 if not GobletifsInInventory then
  14.                     -- Check if we can buy the Item
  15.                     if player.leaderstats.Coins.Value >= Goblet.Price.Value then
  16.                         print(player.Name.." brought the ".. Goblet.Name.." item")
  17.  
  18.                         player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - Goblet.Price.Value
  19.  
  20.                         local bool = Instance.new("BoolValue",player.AccessoriesInventory); bool.Name = Goblet.Name
  21.                        
  22.                         local giveTool = ReplicatedStorage.Accessories:FindFirstChild(Goblet.Name):Clone()
  23.                         giveTool.Parent = player.Backpack
  24.  
  25.                         local giveTool2 = ReplicatedStorage.Accessories:FindFirstChild(Goblet.Name):Clone()
  26.                         giveTool2.Parent = player.StarterGear  
  27.                        
  28.                         return "Brought"
  29.                     else
  30.                         return "NotEnough"                         
  31.                     end
  32.                 else  
  33.                     -- You already owned it      
  34.                     if player.AccessoriesInventory:FindFirstChild("EquippedAccessories"):FindFirstChild("EquippedGoblet").Value ~= Goblet.Name and GobletifsInInventory == true then                                           
  35.                         debounce = false
  36.                         player.AccessoriesInventory:FindFirstChild("EquippedAccessories"):FindFirstChild("EquippedGoblet").Value = Goblet.Name
  37.                        
  38.                        
  39.                         local giveTool = ReplicatedStorage.Accessories:FindFirstChild(Goblet.Name):Clone()
  40.                         giveTool.Parent = player.Backpack
  41.  
  42.                         local giveTool = ReplicatedStorage.Accessories:FindFirstChild(Goblet.Name):Clone()
  43.                         giveTool.Parent = player.StarterGear
  44.                        
  45.                         wait(1)
  46.                         debounce = true
  47.                         return "Equip"                                                                             
  48.                     else
  49.                         player.AccessoriesInventory:FindFirstChild("EquippedAccessories"):FindFirstChild("EquippedGoblet").Value = ""
  50.                        
  51.                         local itemName = "Goblet" --Change this
  52.                         local Char = player.Character or player.CharactedAdded:Wait()
  53.                         local GearInCharacter = Char:findFirstChild("Goblet")
  54.                        
  55.                         if player.Backpack:FindFirstChild(itemName) and player.Backpack[itemName]:IsA("Tool") then
  56.                             player.Backpack.Goblet:Destroy()
  57.                             player.Backpack.Goblet:Destroy()
  58.                             player.StarterGear:FindFirstChild("Goblet"):Destroy()
  59.                             player.StarterGear:FindFirstChild("Goblet"):Destroy()
  60.                         end
  61.            
  62.                         wait(1)
  63.                         debounce = true
  64.                         return "Unequip"
  65.                     end                    
  66.                 end
  67.             end
  68.         end
  69.     end
  70.     wait(1)
  71.     debounce = true
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement