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

I need help with datastore saving levels can someone help?

So i want the game to store the level value which the player is in so that when they join the level will save if they leave. I used a youtube video but get an error on the marked line. Please help.

local DS = game:GetService("DataStoreService")
local ds = DS:GetDataStore("Level")


game.Players.PlayerAdded:connect(function(plr)
	


plr.CharacterAdded:connect (function(charadded)
	wait"1"
		plr.PlayerGui.Gamegui.Enabled = true
		plr.leaderstats.Level.Value = ds:GetAsync(plr.UserID) or 0 -- This is the error line --
		ds:SetAsync(plr.UserID, plr.leaderstats.Level)
		plr.leaderstats.Level.Changed:connect(function()
			ds:SetAsync(plr.UserID,plr.leaderstats.Level)
		end)
		





end)
game.Players.PlayerRemoving:connect (function()
	ds:SetAsync(plr.UserID, plr.leaderstats.Level.Value)	
end)
end)


1 comment

0

If I helped you out please accept my answer. Otherwise comment how I can help you better.

1 answer

Your problem is you are using plr.UserID when the D should be lowercase. Try replacing all of your plr.UserID with plr.UserId hope this helps. Have a great day scripting

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