Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How i edit a value in a table?

Asked by
Kryptio 19
6 years ago
Edited 6 years ago

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.

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. Shawnyg 4330 — 6y

2 answers

Log in to vote
1
Answered by
GingeyLol 338 Moderation Voter
6 years ago
local table = {"ThisChanges"}
table[1] = "IntoThis"
print(table[1])
0
I dont believe this was the answer i was looking for Kryptio 19 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
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.

0
If you have any issues with this, please post and I'll answer liteImpulse 47 — 6y

Answer this question