Heres the script...

local DSService = game:GetService('DataStoreService'):GetDataStore('potomojokolonotofghdghdglsirityru')
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 = 'Level'
	
	-- 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.Level.Value}
DSService:SetAsync(uniquekey, Savetable)	
	
	
end)

4 comments

0

:connect is deprecated, or not recommended. You should use:Connect since :connect might get removed

0

Oh ok i'll try that.

0

This is alvinbloxx’s code.

0

Don’t come on this site with code that isn’t yours and expect it to be fixed.