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

How can I add more data to a dictionary?

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?

2 comments

0

It should work. Try PlayerSata.plr.Weapon[“NewSword”] = 1. 

0

You should also be using the plr.UserId right?

1 answer

✓ Accepted answer

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

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