(196 is printed v directly after loop, 193 is printed v in loop with the correct values).
What solutions have you tried so far? I have tried to use roundStats.v (dictionary name), but it breaks the rest of the program without returning any error messages. I have also tried to use devforum search and github, as well as the roblox documentation, but none of them seem to have this error and/or say to set it regularly with =.
Relevant code:
for i, v in pairs(roundStats) do
roundStats.v = player.Stats:WaitForChild(tostring(i)).Value
print(tostring(v))
end
for i, v in pairs(roundStats) do
print(tostring(v))
end
(maybe) relevant code:
function createValuesOfIn(constructType, valueType, valueTable, valueTable2, valueFolder, parent)
if constructType == "single" then
local newValue = Instance.new(valueType)
newValue.Name = valueTable2
newValue.Value = valueTable
newValue.Parent = parent
else
local newFolder = Instance.new("Folder")
newFolder.Name = valueFolder
newFolder.Parent = parent
if constructType == "dictionary" then
for i, v in pairs(valueTable) do
local value = Instance.new(valueType)
value.Name = i
value.Value = v
value.Parent = newFolder
end
elseif constructType == "array" then
for i, v in valueTable do
local value = Instance.new(valueType)
value.Name = valueTable2[i]
value.Value = v
value.Parent = newFolder
end
else
print("Please enter a valid value!")
end
end
end
createValuesOfIn("dictionary", "IntValue", baseDictionary, "nil", "Stats", player)
(all stats are setting correctly under the correct folder)
for i, v in pairs(roundStats) do
local newValue = [path_to_player].Stats:WaitForChild(i).Value -- Get the stat object value and store it
roundstats[i] = newValue -- set table value as new value (note: 'v' would refer to the current value and thus not change it)
print('updated '..i..' to value: '..newValue) -- confirm we updated the value
end
i is a string, v is a number, path_to_player is just meant to refer to whatever variable you use to represent the player object
for i, v in pairs(roundStats) do
local newValue = [path_to_player].Stats:WaitForChild(i).Value -- Get the stat object value and store it
roundstats[i] = newValue -- set table value as new value (note: 'v' would refer to the current value and thus not change it)
print('updated '..i..' to value: '..newValue) -- confirm we updated the value
end
i is a string, v is a number, path_to_player is just meant to refer to whatever variable you use to represent the player object
Meant to make this a reply not an edit, but don’t want to delete it so here - sorry for the double bump
You can absolutely use a 1 line method, but for the purposes of explaining in comments it made more sense to save it as a variable to be able to compare to more easily. You could also do:
for i, v in pairs(roundStats) do
roundstats[i] = [path_to_player].Stats:WaitForChild(i).Value
end
-- edit: fixed extra space
which doesnt save a variable, and thus theoretically is more efficient from a computing standpoint, but it doesnt explain much
Also, 100% transparency, the entire reason I helped is cause you put a ‘thank you’ in your original post. Sometimes that subtle little stuff makes a difference