I am able to claim my tool as long as I don't already have it in my inventory, I know it has something to do with the backpack == nil but I just can't find another solution around it.
local toolName = script.Parent.Parent.ToolValue.Value
local count = script.Parent.Parent.Count.Value
local amount = script.Parent.Parent.Amount.Value
counter = amount
function onMouseClick(player)
if player:IsInGroup(4893229) then
if player.Backpack:FindFirstChild(toolName) == nil then
if script.Parent.Parent.Count.Value > 0 then
local tool = game.Lighting[toolName]:Clone()
tool.Parent = player.Backpack
script.Parent.Parent.Count.Value = script.Parent.Parent.Count.Value - 1
script.Parent.Parent.Surface.SurfaceGui.TextLabel.Text = tostring(script.Parent.Parent.Count.Value).."/"..tostring(amount)
--script.Parent.Parent.BillboardGui.TextLabel.Text = tostring(count).."/20"
end
end
end
end
script.Parent.MouseClick:connect(onMouseClick)

3 comments
You want the player to claim the tool only once even if equipped or unequipped?
I would edited this but your code is very hard to read and I don't understand it
Sorry about it being all over the place but, Yes I want them to be able to take multiple of the tool and not just one.