Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How i edit a value in a table?

Ok so I know how to make a table and a data store, however, i am facing two issues as far as coding goes. I can't find anything about this in any tutorial or wiki so I figured I would ask here. Anyways I am trying to make a database that will store a players items and stats. but the thing I am struggling to understand is this. Let's say a person has a strength of 5 but increases their level and their strength is now 6. I am not sure how to change this value within a table. sure I know how to change an intvalue but that's not what I'm trying to do. I think it would be much easier working with data in tables rather than creating over a thousand or so Intvalue, StringValue, or BoolValue. Which is why I would like to create a table and edit off that my question is how do I make a change in a table? I hope that made sense.

Ill make a quick example, the player steps on a switch or opens a chest, that chest will contain a 1 potion, so that would increase the total amount that player has in their inventory. I know how to do this for an intvalue or anything physical in game. but when it comes to a table that's where I am completely stomped.

1 comment

0

Gingey's answer reflects the scenario you've described. Given that you haven't provided any code to help us grasp more of an understanding, from the words you've used, Gingey's answer is correct.

2 answers

local table = {"ThisChanges"}
table[1] = "IntoThis"
print(table[1])

1 comment

0

I dont believe this was the answer i was looking for

local table = {["Strength"] = 1}

table.Strength = table.Strength + 1

print(table.Strength)

I'm not in studio now, but I'm sure this works. I haven't worked with tables a lot right now, but I have done Data stores with them.

1 comment

0

If you have any issues with this, please post and I'll answer

This discussion is preserved as it was. New answers, comments, and votes are closed.