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

Why won't this datastore work, nothing saves?

local DSService = game:GetService('DataStoreService'):GetDataStore('theweirdlolsavedata669')
game.Players.PlayerAdded:connect(function(plr)
	local uniquekey = 'id'..plr.userId
	local stuff = Instance.new("Folder", plr)
	stuff.Name = "stuff"
	local Invun = Instance.new('IntValue', stuff)
    Invun.Name = "Stat1"

	
	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		Invun.Value = GetSaved[1]
	else
		local NumbersForSaving = {Invun.Value}
		DSService:SetAsync(uniquekey, NumbersForSaving)
		
	end
end)

game.Players.PlayerRemoving:connect(function(plr)
	local uniquekey = 'id'..plr.userId
	local Savetable = {plr.stuff.Stat1}
	DSService:SetAsync(uniquekey, Savetable)
	
	
	
end)

2 comments

0

is this a server script?

0

yeah, in the workspace

1 answer

✓ Accepted answer

Didn't look too in-depth, however on line 22 you forgot to include ".Value" in the array. If this doesn't solve the problem let me know.

1 comment

1

Works, thank you

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