textbox.InputEnded:Connect(function()
for i, v in pairs(whiteListTableDisplay) do
print(i)
posValue2 = posValue2 + 0.05
local newLabel = Instance.new('TextLabel')
newLabel.Parent = scFrame
newLabel.Position = UDim2.new(0.497, 0, posValue2 , 0)
newLabel.Size = UDim2.new(0.499, 0,0.031, 0)
newLabel.FontFace.Bold = true
newLabel.Text = tostring(v)
newLabel.TextScaled = true
newLabel.TextColor3 = Color3.new(1, 1, 1)
end
end)
However this is not an ideal solution and keeps spamming new text labels when input begins, or ends again.
How would I make it so when input stops and in the for loop each value will be “refreshed” and not cloned with a different position if it’s the same value
local previousLabel = {}
textbox.InputEnded:Connect(function()
for i, instance in ipairs(previousLabel) do
instance:Destroy()
end
for i, v in pairs(whiteListTableDisplay) do
posValue2 = posValue2 + 0.05
local newLabel = Instance.new('TextLabel')
newLabel.Parent = scFrame
newLabel.Position = UDim2.new(0.497, 0, posValue2 , 0)
newLabel.Size = UDim2.new(0.499, 0,0.031, 0)
newLabel.FontFace.Bold = true
newLabel.Text = tostring(v)
newLabel.TextScaled = true
newLabel.TextColor3 = Color3.new(1, 1, 1)
table.insert(previousLabel, newLabel)
end
end)
NOTE: This is not efficient code, I have no idea what you are trying to do with this code, more details might make it better.
it just now has weird behavior like the first time i add something, it doesn’t create, then the 2nd time it creates, then the 3rd time it creates like 5 times
im trying to make a whitelist system, i dont want the instances to delete but when I remove that line is starts breaking and text labels are creating/not creating
What does each entry represent?
Are these scores, so can be linked to a player?
The reason I ask, is because if you can have a key (either an index, or playerId, etc…) then you can just check to see if a text label with the same key exists, and if so, use that label, if not, create a new one.
Problem: It keeps incrementing the other label positions instead of incrementing the new label
Code:
local previousLabel = {}
textbox.InputEnded:Connect(function()
for i, instance in ipairs(previousLabel) do
instance:Destroy()
end
for i, v in pairs(whiteListTableDisplay) do
posValue2 = posValue2 + 0.05
local newLabel = Instance.new('TextLabel')
newLabel.Parent = scFrame
newLabel.Position = UDim2.new(0.497, 0, posValue2 , 0)
newLabel.Size = UDim2.new(0.499, 0,0.031, 0)
newLabel.FontFace.Bold = true
newLabel.Text = tostring(v)
newLabel.TextScaled = true
newLabel.TextColor3 = Color3.new(1, 1, 1)
table.insert(previousLabel, newLabel)
end
end)
This issue I believe is caused by automatic size on the Scrolling frame, if this is the case, try changing the scrolling frame size whenever you add or remove a child to it.