Cannot add property 'x' to table

I have a module that allows access to NumberValues and StringValues parented to it. It is in ReplicatedStorage.
image

The code inside of “Gamestate”

image

When getting values, it doesn’t give me warnings. When setting values, it does.

image

image

image

What can i do?

heyo!

i don’t think this is the right way to go about it, let’s say that you want to get a value from one of these instance values.

that for one, would work with this code like so: gamestate["Map"]. however, if you want to set a value, you cannot do gamestate["Map"] = value. this is because you are returning the value and not the object itself.

to counter this problem i would just return the object itself and when i’d need to get the value, do the following; gamestate["Map"].Value. and this way you can also set values like so: gamestate["Map"].Value = value

hope this helped you!

Solved the problem. Seems like the warning is telling me the table is read-only, since __newindex overrides the value assignment.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.