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

Is there a way to save Variables on Scripts in Player Data?

Seems weird to be doing it this way but if there is a better option then please let me know. Basically I have variables to confirm and do things if variables are a certain state for a player. Is there a way I can save those variables on Player Saved Data to make things easier and more optimized to keep me from going crazy in finding ways around it. Since I don't know a direct counter option from doing things a better way.

Thanks In Advance!

1 answer

Ok, so I'm supposing you know how to retrieve player data. If you can then continue reading. So I am probably thinking that you need help setting variables in your player data if so then you do it like this

ds = game:GetService("DataStoreService"):GetDataStore("lolscriptinghelpers.org")
-- ignoring the fact the rest of the script isnt here, you would do this
whatneedssaving = {var1, var2, var3}
ds:SetAsync(plr.UserId, whatneedssaving)

There is a max limit to the amount you can save in datastore so be wary of that. Also, on another note, I believe you can't save parts directly into the datastore but you can sort it into necessary info and unnecessary info to use later.

~tantec

1 comment

0

Yea I know how to retrieve. I think I should have mentioned this beforehand but I would like all of Data Saving on one script (respectively per thing I'm actually saving). Now with that being said all I know right now to make things accessible universally is by using _G. but I feel for safety reasons I need a better way. I have an idea on what I could do but I'm not really 100% sure.

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