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

Help with Instances and tables?

I just want one value to go in a text box,but I get all six values in a text box. For example,I want text box 1 to just have the value of 1 and text box 2 to have the value of 2.


-------------Table-------------
names = {"yo","2","3","4","5","6" }--The names
values = {"13123","1232","3123","1234","1235","612312"}--The values
----ScrollingFrame Creation-----
s = Instance.new("ScrollingFrame",script.Parent)--Makes the ScrollingFrame
s.Position = UDim2.new(0,50,0,30)
s.Size = UDim2.new(0,700,0,540)
s.CanvasSize = UDim2.new(0,0,6,6)
----TextButton Table Creation-----
for i,v in pairs (names) do
print(v)--Test Test
h = Instance.new("TextButton",s)--Puts it all in the ScrollingFrame
h. Text = v
h.Name = v
h.Size = UDim2.new(0,100,0,100)
------Value Creation--------------
for x,n in pairs (values) do
str = Instance.new("StringValue",h)
str.Name = values[x]
  str.Value = values[x]
end
----TextButton Sorting------------
 h.Position = UDim2.new(0, 0, 0, (i*100)-100)--For each name move up one
end



1 comment

0

Edited because I forgot to put the values.

1 answer

✓ Accepted answer
-------------Table-------------
names = {"1","2","3","4","5","6" }--The names
values = {"1","2","3","4","5","6"}--The values
----ScrollingFrame Creation-----
s = Instance.new("ScrollingFrame",script.Parent)--Makes the ScrollingFrame
s.Position = UDim2.new(0,50,0,30)
s.Size = UDim2.new(0,700,0,540)
s.CanvasSize = UDim2.new(0,0,6,6)
----TextButton Table Creation-----
for i,v in pairs (names) do
print(v)--Test Test
h = Instance.new("TextButton",s)--Puts it all in the ScrollingFrame
h. Text = v
h.Name = v
h.Size = UDim2.new(0,100,0,100)
------Value Creation--------------
str = Instance.new("StringValue",h)
str.Name = values[i]
  str.Value = values[i]
----TextButton Sorting------------
 h.Position = UDim2.new(0, 0, 0, (i*100)-100)--For each name move up one
end


3 comments

0

Sorry I edited,but I wanted it to be connected the the table named values not i.

0

IT ALRDY IS CONNECTED TO THE TABLE NAMED VALUES. I IS A PARAMETER IF YOU DONT KNOW WHAT THIS IS LOOK IT UP ON WIKI

0

Sorry >.>

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