heres my script that i dont have a clue why dont work
local savedatas = -- the table
{
Reflections = false;
Ambients = false;
Extras = false;
Shadows = false;
other = false;
}
for i,v in pairs(savedatas) do
v = true
print(v, i) -- prints the value and then name
end
print(savedatas) -- prints the table, it prints it before changes not after setting it to true basically it says that all values are false even though i changed it to true
for i,v in savedatas do
savedatas[i] = true
--print(v, i) -- prints the value and then name
--The above line won't work because I didn't change v itself, which is the value..
end
My guess if that your making the variable, v, itself true, and not affecting the table at all
The issue with your script is that when you loop through the table using for i, v in pairs(savedatas) do, the variable v represents the value at the current index, but it’s a copy of that value, not a reference to it. So when you do v = true, you are only changing the local variable v within the loop and not updating the actual value in the savedatas table.
To correctly update the values in the savedatas table, you should use the table index i to access and modify the values. Here’s the corrected version of your script:
local savedatas = {
Reflections = false;
Ambients = false;
Extras = false;
Shadows = false;
other = false;
}
for i, _ in pairs(savedatas) do
savedatas[i] = true
end
print(savedatas)