Title explains everything. Here's my code.
local datastore = game:GetService("DataStoreService"):GetDataStore("justatestkeyforforumnotactualcode") game.Players.PlayerAdded:connect(function(plr) local key = "ID-"..plr.UserId local getSaved = datastore:GetAsync(key) local keydata1 = Instance.new("BoolValue", plr) local keydata2 = Instance.new("StringValue", plr) keydata1.Name = "WindforceBoughtSave" keydata2.Name = "EquippedSwordSave" if getSaved then keydata1.Value = getSaved -- This is where I'm confused. This is the bool value. keydata2.Value = plr.PlayerGui.EquippedSword.Value -- This is also where I'm confused. This is the string value. else local saved1 = {keydata1.Value} local saved2 = {keydata2.Value} datastore:SetAsync(key, saved1, saved2) end end) game.Players.PlayerRemoving:connect(function(plr) local key = "ID-"..plr.UserId local savetable1 = {plr.PlayerGui.EquippedSword.Value} local savetable2 = {plr.PlayerGui.WindforceBought.Value} datastore:SetAsync(key, savetable1, savetable2) end)
So, how would I do this? I'm extremely confused at this situation. I've also read the API:Class/HttpService/GetAsync thing too.
You need to read the DataStore manual, which will explain how to use DataStores properly. Specifically, you can only save a single value to a datastore key, but that value can be a table that contains other values. It looks like you want to save/load 2 values, a string and a bool? In that case, simply save a table where the first value is the string and the second is the bool (or vice versa) (see below). Load that table into your variable as you do on line 6 and then read from the table on lines 12 and 13 (ex for 12 you'd use getSaved[1]
if the first value was the boolean).
Code to save is local saved = {keydata1.Value, keydata2.Value}
and datastore:SetAsync(key, saved)
.