Hello, I have question where is problem/error in this script? It should sell certain item from starterpack, but it always says "You don't have...", when i hold it in backpack. I tried some changes, but didn't work. It's not my script, my friend made it.
Here is script:
local tabs = script.Parent.TABS:GetChildren()
for i = 1, #tabs do
local buttons = tabs[i]:GetChildren()
for i = 1, #buttons do
function sell()
local hint = Instance.new("Hint",script.Parent.Parent.Parent.Parent.PlayerGui)
local gp = script.Parent.Parent.Parent.Parent.leaderstats:FindFirstChild("Gold")
local bp = script.Parent.Parent.Parent.Parent.Backpack
local sg = script.Parent.Parent.Parent.Parent.StarterGear
local bptool = bp:FindFirstChild(buttons[i].Item.Value)
local sgtool = sg:FindFirstChild(buttons[i].Item.Value)
local sellvalue = buttons[i].SellPrice.Value
if bptool ~= nil and sgtool ~= nil then
bptool:Remove()
sgtool:Remove()
gp.Value = gp.Value + sellvalue
hint.Text = "You sold " ..buttons[i].Text.. " for " ..buttons[i].PriceDisplay.Text.. " Gold!"
elseif bptool == nil and sgtool ~= nil then
sgtool:Remove()
gp.Value = gp.Value + sellvalue
hint.Text = "You sold " ..buttons[i].Text.. " for " ..buttons[i].PriceDisplay.Text.. " Gold!"
else hint.Text = "You don't have " ..buttons[i].Text.. "!"
end
local cl = script.Clean:Clone()
cl.Parent = hint
cl.Disabled = false
end
buttons[i].MouseButton1Click:connect(sell)
end
end

1 comment
This code checks for tools you have in the users' backpack, if the user is holding it in their hand it won't work. Plus, if the user picked up the tool off the ground, the code won't work because it checks for the Startergear as well