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

How can I add more data to a dictionary?

Asked by 4 years ago

I am using a dictionary to store the number of items a user currently has. I want to be able to add a new key-value to my dictionary for new items.

My dictionary looks like this: ["Weapon"] = { Sword = 0, test = 0 }

This is saved inside a datastore so for access to the dictionary you do: PlayerData[plr]["Weapon"]

I have seen posts and videos where they do: key="NewSword" PlayerData[plr]["Weapon"][key] = 1 but that doesn't work.

How could I go about doing this?

0
It should work. Try PlayerSata.plr.Weapon[“NewSword”] = 1.  SethHeinzman 284 — 4y
0
You should also be using the plr.UserId right? SethHeinzman 284 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Can't you just do PlayerData[plr]["NewKey"] = {--Different Items} and just save PlayerData[plr] instead of PlayerData[plr]["Weapon"]

Ad

Answer this question