Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can you fix this Inventory/Backpack Limit? (No Error In Output)

Asked by 3 years ago

There is no error or anything, but when somebody purchases it, it says that the player is under the limit, when they reach over 15 tools, it still says it, could somebody help me.

local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local pack = player:WaitForChild("Backpack"):GetChildren() 
local replicatedstorage = game:GetService("ReplicatedStorage")

     script.Parent.MouseButton1Click:connect(function()
       if #pack >= 15 then
                print("This player has to many items")
                pack:Destroy()
                replicatedstorage.ClassicSword:Clone()
                     end
       if #pack <= 15 then
        print("Player Is Under Limit")
       if player.Data:FindFirstChild("Coins").Value >= price.Value then
       player.Data:FindFirstChild("Coins").Value = player.Data:FindFirstChild("Coins").Value - price.Value
        game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)

  end
 end
end)

This is a LocalScript that functions when somebody clicks the textbutton. There already is a leaderstats and everything. Any possible clue?

1 answer

Log in to vote
1
Answered by 3 years ago
local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = game.Players.LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")

     script.Parent.MouseButton1Click:connect(function()
local pack = player:WaitForChild("Backpack"):GetChildren() 
       if #pack >= 15 then
                print("This player has to many items")
                pack:Destroy()
                replicatedstorage.ClassicSword:Clone()
                     else
       if #pack <= 15 then
        print("Player Is Under Limit")
       if player.Data:FindFirstChild("Coins").Value >= price.Value then
       player.Data:FindFirstChild("Coins").Value = player.Data:FindFirstChild("Coins").Value - price.Value
        game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
end
  end
 end
end)

Try this!

Ad

Answer this question