Hi, so I'm making a scanner, basically when you click a box it adds the item to your inventory and adds a label to the GUI, that's all working but I want to make it so that it can be removed.
So I've got this code snippet I've tried, I'll also attach an image of the explorer.
ScanAndGo.MainApplication.ProductsList.ChildAdded:Connect(function() for i,Label in pairs(ScanAndGo.MainApplication.ProductsList:GetChildren()) do if Label.Name ~= "ListLayout" then Label.Remove.MouseButton1Click:Connect(function() local Position = Label.Pos.Value local Price = Label.Price.Value table.remove(ProductTable,Position) TransactionData.Total = TransactionData.Total - Price icon1:setLabel("Total: "..Settings.Currency..string.format('%.2f', TransactionData.Total)) ScanAndGo.MainApplication.Total.Text = Settings.Currency..string.format('%.2f', TransactionData.Total) showNotification("Neutral",Label.ProductName.Text .." removed from your basket.",1.5) Label:Destroy() end) end end end)
I get an error in the output:
Players.jxdxn_14.Backpack.Phone.UI.LocalPhone:780: attempt to index function with 'MouseButton1Click'
This is a local script by the way, not sure if that matters
And here I'll attach a link to an image of the explorer ????
https://cdn.discordapp.com/attachments/785108506084507660/1036195550485299241/unknown.png
Let me know how I can fix it ????
thank u
I can't see the explorer because I don't have access to the message. And also. MouseButton1Click is an event. when you click the whatever you have to click it triggers that event so I don't see why you have it in a function. Basically:
ScanAndGo.MainApplication.ProductsList.ChildAdded:Connect(function() for i,Label in pairs(ScanAndGo.MainApplication.ProductsList:GetChildren()) do if Label.Name ~= "ListLayout" then local s = script.LocalScript:Clone s.Parent = Label s.Enabled = true end end end)
make a local script in that other script and put this code inside it. then disable the local script
Label.Remove.MouseButton1Click:Connect(function() local Position = Label.Pos.Value local Price = Label.Price.Value table.remove(ProductTable,Position) TransactionData.Total = TransactionData.Total - Price icon1:setLabel("Total: "..Settings.Currency..string.format('%.2f', TransactionData.Total)) ScanAndGo.MainApplication.Total.Text = Settings.Currency..string.format('%.2f', TransactionData.Total) showNotification("Neutral",Label.ProductName.Text .." removed from your basket.",1.5) Label:Destroy() end)