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

My data store won't save anything, what's the issue?

script:

local DSService = game:GetService('DataStoreService'):GetDataStore('fakedataSnameforSHcom')
game.Players.PlayerAdded:connect(function(plr)
	-- Define variables
	local uniquekey = 'id-'..plr.userId
	local leaderstats = Instance.new('IntValue', plr)
	local savevalue =  Instance.new('IntValue')
	leaderstats.Name = 'leaderstats'
	savevalue.Parent = leaderstats
	savevalue.Name = 'Clicks'
	
	-- GetAsync
	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
	else
		local NumbersForSaving = {savevalue.Value}
		DSService:SetAsync(uniquekey, NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Clicks.Value}
DSService:SetAsync(uniquekey, Savetable)	
	
	
end)

credit to AlvinBlox ^, tried to make my own use the DataStore wiki, but that didn't work. His also doesn't work. Does any

3 comments

0

Capital 'U' in UserId, also use Connect not connect.

0

Also enabled API services to your game

0

alivnblox. Thats the issue

1 answer

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