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

how do i use in pairs but with noo loop? [closed]

Asked by 5 years ago

here is script

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local plr = game.Players.LocalPlayer
    local i = Instance.new("TextLabel",plr.PlayerGui.pack.Frame)
    if (humanoid ~= nil) then   
 for _,tools in pairs(plr.Backpack:GetChildren()) do
    if tools:IsA("Tool") then

        i.Text = tools.Name
        print(tools.Name)
    end

end
    end
end)
0
Uh i dont understand your question, what are you trying to do here? aazkao 787 — 5y
0
i am trying to get the tools from player back pack but i keeps on making more like i have one tool but it make like 7 ;-; helleric -3 — 5y
0
add a break Decimaprism 65 — 5y
0
..?? helleric -3 — 5y
View all comments (2 more)
0
break the loop when you find the tool theking48989987 2147 — 5y
0
how thou helleric -3 — 5y

Closed as Not Constructive by shayner32, chexburger, green271, zblox164, and User#21908

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 5 years ago
script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    local plr = game.Players.LocalPlayer
    local i = Instance.new("TextLabel",plr.PlayerGui.pack.Frame)
    if (humanoid ~= nil) then  
 for _,tools in pairs(plr.Backpack:GetChildren()) do
    if tools:IsA("Tool") then
        i.Text = tools.Name
        print(tools.Name)
    break -- This is what aazkao means by break
   end
end
    end
end)
0
And I assume thats where you want your break to be right? PenguinDevs 45 — 5y
Ad