Title is actually quite misleading as I already know how to do that, but I have a problem with the values not setting afterwards.
--keys: Several stringvals in a folder
--hotkey: Textlabel (textbox as descendant)
for _, v in pairs (keys:GetChildren()) do
for i = 1, #hotkey do
if v.Name == hotkey[i].Name then
print('true') -- prints it once after it iterates through everything else
v.Value = hotkey[i].TextBox.Text
end
end
end
No errors. I guess setting v’s value affected the rest of the values as well. Any insight?
Sorry I wasn’t quite clear. Hotkey is a frame that holds textlabels. Whenever I tweaked it a bit, the text does show up, but it seems like its setting to the first value that I put. I guess im setting them all to one value.
Trying to make a temporary save system for a hotkey system that I have.
Keys: Folder with stringvalues (Name of skills that will be binded)
HotKey: Frame that holds textlabels (with textbox as descendant) and share the same amount and names with ‘Keys.’
Well, as the title says, im comparing both values from their respective tables, which works up to that point btw.
The # operator is only used to determine the length of strings, or tables. Using on a Frame GUI object will not work. Are you trying to get the number of Children inside the Frame?
The textboxes are running a changed event, so I fire that snippet of a whole to change the key’s value to the key that was inputted. Then I have the character on spawn input the key’s value to their hotkeys (textlabel>textbox)
You aren’t wrong, but just above that code (didnt show it as I explained it already), I iterated the hotkey, and the # operator is ran in a for loop so it runs the amount of children it has.
I still don’t entirely get the purpose of your code. All your given us is a snippet and we’re left to guess what you’re using it for, what might be wrong and what alternatives there could be.
That snippet is literally the main idea of the code, but if it’ll help then heres the full code:
local Change = function(plyr, input)
local char = plyr.Character
local values = plyr:FindFirstChild("Values")
local keys = values:FindFirstChild("Keys")
local ui = plyr.PlayerGui:FindFirstChild("UI")
local hotkey = ui:FindFirstChild("Hotkey"):GetChildren()
for k, v in pairs (keys:GetChildren()) do
for i = 1, #hotkey do
if v.Name == hotkey[i].Name then
local tb = hotkey[i]:FindFirstChild("TextBox")
if tb then
v.Value = input
end
--v.Value = tostring(hotkey[i].Name)
end
end
end
--
end
remote.OnServerEvent:connect(Change)