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

Weird Error ive never seen When using datasave script ???

Heres Error: GetAysnc is not a valid member of GlobalDataStore

local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local save1 = plr.leaderstats.Fish
	local save2 = plr.leadersats.Pearls
	
	local GetSaved = ds:GetAsync(plrkey)
	if GetSaved then
		save1.Value = GetSaved[1]
		save2.Value = GetSaved[2]
	else
		local NumberForSaving = {save1.Value, save2.value}
		ds:GetAsync(plrkey, NumberForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:GetAysnc("id_"..plr.userId, {plr.leaderstats.Pearls.Value, plr.leaderstats.Fish.Value})
end)

Hope You Can Help!

2 answers

You're error is at Line 19

you put "GetAsync", instead of "SetAsync", and when it's trying to GetAsync of the saved data, there's none cause your not saving any.

here's your fixed code:

local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
    wait()
    local plrkey = "id_"..plr.userId
    local save1 = plr.leaderstats.Fish
    local save2 = plr.leadersats.Pearls

    local GetSaved = ds:GetAsync(plrkey)
    if GetSaved then
        save1.Value = GetSaved[1]
        save2.Value = GetSaved[2]
    else
        local NumberForSaving = {save1.Value, save2.value}
        ds:GetAsync(plrkey, NumberForSaving)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local key = "id_"..plr.userId"
    local DataToSave = {plr.leaderstats.Pearls.Value, plr.leaderstats.Fish.Value}
    ds:SetAysnc(key, DataToSave)
end)

Hope this helps :)

3 comments

0

This isnt working

0

did you try leaving, then rejoining?

0

yes i did

Spelling error you did GetAysnc instead of GetAsync

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