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

i am using in pairs for a tools but it keeps on printing the first tool in my hot-bar how do i fix?

Asked by 5 years ago

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)
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. xPolarium 1388 — 5y
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 helleric -3 — 5y
0
I never use IsA, I always use ClassName greatneil80 2647 — 5y
0
class name dose not work for me helleric -3 — 5y

Answer this question