Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i check how many of a tool is in a player's inventory?

Asked by 3 years ago

I have a script that checks if you have more than one tomato picked up in your inventory, then tells you that you already have one if you already have one, with a gui controlled by a module script "wait"

but i dont know how to check how many of a tool is inside your inventory

cd.MouseClick:Connect(function(humanoid)

if db then
        db = false
    local inv = humanoid.Backpack 
    local tool = game.ServerStorage["Tomato"]
    tool:Clone().Parent = inv
        wait(2)
        if humanoid.Backpack.Tomato > 0 then --i dont know how to check 
            waitgui.enableAndDisable() --enableAndDisable is a function inside the module
            db = true
                end
          end
end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
if #humanoid.Backpack:GetChildren()>0 then
--check 
0
Please read the note and adjust your answer accordingly. appxritixn 2235 — 3y
0
yea i get that he didnt explain it but it works so thanks unlostcorp 16 — 3y
0
add friend me and i will help you make game bro lehoaiquoc248 23 — 3y
Ad

Answer this question