I know that it may sound weird but this values doesn’t want to change like at all
local rarities = {rare = true, epic = false, legendary = false}
for i, v in rarities do
if v == true then
print(v)
v = false
print(v)
end
end
print(rarities)
like the game does detect some value being true in it but at the same time when I check the same table outside the for loop all the values are still the same. I’m sorry if the solution is super easy but I actually don’t know what is the cause of this
In your loop you have the variable v. This value is a Boolean, and in Luau when it is assigned in this manner it is copied - that is to say modifying it will not modify the original. If you want to modify the original you need to set the table value, not your local copy.
Because i and v are variables, and variables are meant to act as temporary storages of values. This is the how variables are treated for most general purpose programming languages (i.e. Python, C, Rust, Zig), and it’s more practical than what you might think.
Mhm, I would know. But let us not introduce such concepts to a feedback post from someone who’s only beginning, as this might nerdsnipe them — and since they aren’t prepared to tackle such concept — might cause them further confusion.