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)
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