Changing data of a player that is not in game

Trying to make the players give gifts to each other even if they are offline. The player who is sending types the username in the textbox and then it changes the receiver’s gift value from 0 to 1 indicating they got a gift. This doesn’t seem to work though. I appreciate any help.
image

Are there any errors with this script?

Well. yes it says attempt to index number with Gift

you can just change the highlighted line to

guildmemberval.Gift.Value += 1

Still doesn’t work. Is there a way to get a specific value from the UserId or the GetDataStore function?

Datastore values don’t have a .Value. it takes in a Tuple, which can be a table of values, or just a number. Can I ask how you save data? You need to edit it like how you edit the data for saving to the datastores.

Ok so when the player joins it clones the storage folder and set the players values according to each folder/numbervalue name
image

So your stored data is a table in my guess.
Note that there isnt any option to actually save an Instance in a datastore.
So to solve this problem (if if is a table) you need to get rid of the Value “property” since it doesnt exist. Also if its not a table you only have to change the number itself, nothing with a name included.

How are you saving it? It has to somehow be serialized, you cant save Instances in datastores.

image not folder is the Storage folder you saw

Alright, I see that your data is saved by key = value. Instead of guildmemberval.Gift.Value += 1, you can just use guildmemberval.Gift += 1, without the .Value.

image

1 Like

guildmemberval is the Player’s UserID

No its not, in the script you sent it clearly is the datastore entry.

Ok so, is seems like it worked but when I tested it it didn’t change the value for some reason.
image

How do you know if it worked or not? The error is irrelevant. How do you load your data?

This is the error image

and if you want the script of how I load it this is how.
image

I found a way to fix it, if you want to see, I had the replicated the whole folder and put all the data inside each of the numbervalues to access the data.
image

You should probably use modules instead of instance values.

I am not very good with modules so I’ll keep my solution until I learn more about it, thanks for the suggestion though!

1 Like