Hello, For some reason just out of nowhere my code just started bugging, It just doesn’t register clicks on some buttons or it does but after spamming the poop out of it. I just want to fix this issue. I marked where the problem is. Thanks!
function updateMerchant(stock, inventory)
--remove
for _,existingButtons in ipairs(hud.Merchants.MerchantFrame.frame:GetChildren()) do
if existingButtons:IsA("ImageButton") then
existingButtons:Destroy()
end
end
--
for _,existingButtons in ipairs(hud.Merchants.SellFrame.frame:GetChildren()) do
if existingButtons:IsA("ImageButton") then
existingButtons:Destroy()
end
end
--
--
for _, itemData in pairs(stock) do
local itemName = itemData.Name
local itemLabel = game.Lighting.InventoryButtons[itemName]:Clone()
itemLabel.itemName.Text = itemLabel.Name
itemLabel.Parent = merchantFrame.MerchantFrame.frame
AdjustSize(itemLabel.UISizeConstraint, itemLabel)
if itemData.Price <= 0 then
itemLabel.itemPrice.Text = itemData.SellPrice
itemLabel.itemPrice.Visible = true
merchantFrame.BuyFrame.Visible = false
else
itemLabel.itemPrice.Visible = false
merchantFrame.BuyFrame.Visible = true
end
itemLabel.MouseButton1Click:Connect(function()
print("Clicked") -- PROBLEM HERE, Even when clicking it doesn't seem to print the string
if merchantFrame.BuyFrame.SelectedItem.Value ~= nil and itemData.Price ~= 0 then
merchantFrame.BuyFrame.SelectedItem.Value = itemName
if merchantFrame.BuyFrame.SelectedItem.Value then
local buyframe = merchantFrame.BuyFrame
buyframe.ItemIcon.Image = itemData.Icon
buyframe.ItemName.Text = itemName
buyframe.Description.Text = itemData.Description
buyframe.Price.Text = comma_value(itemData.Price) .. " ₽"
end
end
end)
end
for _, itemData in pairs(inventory) do
if merchantHandlerModule[merchantFrame.Merchant.Value][itemData] then
local itemLabel = game.Lighting.InventoryButtons[itemData]:Clone()
itemLabel.itemName.Text = itemData
itemLabel.itemPrice.Text = comma_value(merchantHandlerModule[merchantFrame.Merchant.Value][itemData].SellPrice)
itemLabel.itemPrice.Visible = true
itemLabel.Parent = merchantFrame.SellFrame.frame
AdjustSize(itemLabel.UISizeConstraint, itemLabel)
itemLabel.MouseButton1Click:Connect(function()
if not selling then
selling = true
game.ReplicatedStorage.Events.SellItem:FireServer(merchantFrame.Merchant.Value, itemData)
if itemLabel:FindFirstChild("slot") then
game.ReplicatedStorage.TLS_sys.events.loadSlot:FireServer("", game.Lighting.InventoryButtons[itemData].slot.Value)
elseif itemLabel:FindFirstChild("Backpack") then
game.ReplicatedStorage.Events.ChangeWeight:FireServer(25)
hud.Frame.Loadouts.ld.Backpack.Image = "rbxassetid://0"
end
itemLabel:Destroy()
task.wait(.1)
selling = false
end
end)
end
end
for _, ammoData in pairs(plr.AmmoFolder:GetChildren()) do
if merchantHandlerModule[merchantFrame.Merchant.Value][tostring(ammoData)] then
if ammoData.Value >= 10 then
local itemLabel = game.Lighting.InventoryButtons[ammoData.Name]:Clone()
itemLabel.itemName.Text = tostring(ammoData)
itemLabel.itemPrice.Text = comma_value(merchantHandlerModule[merchantFrame.Merchant.Value][tostring(ammoData)].SellPrice) .. "|" .. ammoData.Value
itemLabel.itemPrice.Visible = true
itemLabel.Parent = merchantFrame.SellFrame.frame
AdjustSize(itemLabel.UISizeConstraint, itemLabel)
itemLabel.MouseButton1Click:Connect(function()
if not selling then
selling = true
game.ReplicatedStorage.Events.SellItem:FireServer(merchantFrame.Merchant.Value, tostring(ammoData))
task.wait(.1)
itemLabel.itemPrice.Text = comma_value(merchantHandlerModule[merchantFrame.Merchant.Value][tostring(ammoData)].SellPrice) .. "|" .. ammoData.Value
selling = false
end
if ammoData.Value < 10 then
itemLabel:Destroy()
end
end)
end
end
end
end
---///