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

What did I do incorrectly with this DataStore script?

Hello,

I'm trying to learn DataStores and I'm unsure why this isn't working in Studio.

I've made sure the serverscript is in the serverscriptstorage and HTTP requests are on and also the allow studio API option.

-- Services

local DataStoreService = game:GetService("DataStoreService"):GetDataStore("SaveData")


-- DataStore

game.Players.PlayerAdded:connect(function(plr)
	wait()
	local GetSaved = DataStoreService:GetAsync("id_"..plr.userId)
	if GetSaved then
		plr.leaderstats.Cash.Value = GetSaved[1]
	else
		local NumberForSaving = {plr.leaderstats.Cash.Value}
		DataStoreService:GetAsync("id_"..plr.userId, NumberForSaving)
	end
end)


game.Players.PlayerRemoving:connect(function(plr)
	DataStoreService:SetAsync("id"..plr.userId, {plr.leaderstats.Cash.Value})
end)


Thanks in advance for any help and feel free to set me a challenge to expand upon my knowledge of datastores.

1 answer

I dont think it goes in serverscriptstorage try serverscriptservice I have always used that

1 comment

0

Sorry, I meant I have it in the serverscriptservice not storage.

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