i am trying to get all the tools in player backpack

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local plr = game.Players.LocalPlayer

    if (humanoid ~= nil) then   
 for d,tools in pairs(plr.Backpack:GetChildren()) do 

    local i = Instance.new("TextLabel")
    local find = plr.PlayerGui:FindFirstChild("pack")
    i.Parent = find.Back
    if tools:IsA("Tool") then   
        i.Text = tools.Name
        print(tools.Name)
        break

    end
end
    end
end)

4 comments

0

Do you want to print out every name of the tools? Line 14, break, will "break" the for loop after the condition is passed. Remove that if you want to continue printing every tool name.

0

no the print is just there ill remove it later i am trying to make it so that its a gui i have a frame of it so i just got textbox and put the names of the tools there that is what i am trying to do

0

I never use IsA, I always use ClassName

0

class name dose not work for me