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)
Why Do You Have So Many Values In You Model? Instead Of The Script?
Anyways, this should work:
local toolName = script.Parent.Parent.Name -- Whatever Name You Want It To BE local count = 0 -- Whatever Number You Want It At local amount = "" -- Whatever You Want It To Be local tool = game.Lighting[toolName]:Clone() counter = amount function onMouseClick(player) if player:IsInGroup(4893229) then print(player) if not player.Backpack:FindFirstChild(toolName) and count >= 0 then tool.Parent = player.Backpack count = count - 1 script.Parent.Parent.Surface.SurfaceGui.TextLabel.Text = tostring(count).."/"..tostring(amount) script.Parent.Parent.BillboardGui.TextLabel.Text = tostring(count).."/20" elseif player.Backpack:FindFirstChild(toolName) and count < 0 then tool.Parent = player.Backpack count = count - 1 script.Parent.Parent.Surface.SurfaceGui.TextLabel.Text = tostring(count).."/"..tostring(amount) script.Parent.Parent.BillboardGui.TextLabel.Text = tostring(count).."/20" end end end script.Parent.MouseClick:connect(onMouseClick)