Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i use in pairs but with noo loop?

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)

6 comments

0

Uh i dont understand your question, what are you trying to do here?

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 ;-;

0

add a break

0

..??

0

break the loop when you find the tool

0

how thou

1 answer

✓ Accepted answer
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)

1 comment

0

And I assume thats where you want your break to be right?

This discussion is preserved as it was. New answers, comments, and votes are closed.