Seller Code not Working

Sorry, but the title was a bit misleading, and although The code that I have isnt working, its more that i just dont know how to do it, I am trying to make it so that each textbuttons text gets changed to a tool in the players backpack, but only as many as the player has, but it just makes all of the textbuttons text the last tool that it went over.

local player = game:GetService("Players").LocalPlayer
local char = player.Character
while true do
	task.wait(0.1)
	for i, textbutton in ipairs(script.Parent:GetChildren()) do
		if textbutton:IsA("TextButton") then
			for i, v in ipairs(player.Backpack:GetChildren()) do
				if v:IsA("Tool") then
					local tool = v
					if tool.ScrapValue then
						if textbutton.Text == tool.Name.. " - ".. tool.ScrapValue.Value then
						else
							textbutton.Text = tool.Name.. " - ".. tool.ScrapValue.Value
						end
					end
				end
			end
		end
	end
end

robloxapp-20240719-1311472.wmv (2.7 MB)

1 Like

Try looping through the backpack first, then use the index to set the text of the corresponding button to what you want.

1 Like

I could, But I dont want to manually do it for every button, and Looping through the button has not worked(as shown in the code)

1 Like

How are the text buttons generated when the UI opens? It may be more efficient to set the text directly during their creation rather than doing so separately.

3 Likes

Thats Actually A Really Good Idea, Beforehand the text buttons had already been there, but making the text buttons in the script, and then setting their text fixes many problems that my previous code had, thank you!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.