I'm i doing it right?

ServerStorage = game:GetService('ServerStorage')
game.Players.PlayerAdded:connect(function(plr)
plr:WaitForDataReady()
local PlayersStats = Instance.new("ObjectValue", ServerStorage)
PlayersStats.Name = plr.Name.."_Stats"
local NewPlayerStats = Instance.new("BoolValue", PlayersStats)
NewPlayerStats.Name = "NewPlayer"
NewPlayerStats.Value = true
----------------------------------------
local PlayerStatsSaved = plr:LoadObject("PlayersStats")
local SavedNewPlayerStats = plr:SaveBoolean("NewPlayerStats")
if SavedNewPlayerStats == true then
SavedNewPlayerStats = false
end
NewPlayerStats.Value = SavedNewPlayerStats

end)

game.Players.PlayerRemoving:connect(function(plr)
plr:WaitForDataReady()
local PlayersStats = ServerStorage:FindFirstChild(plr.Name.."_Stats")
if not PlayersStats then return end
local NewPlayerStats = ServerStorage:FindFirstChild(NewPlayerStats.NewPlayer)
if not NewPlayerStats then return end
plr:SaveBoolean("NewPlayerStats", false)
end)

3 comments

1

Please explain a little more on what you're trying to accomplish, and post any error message if there are any.

0

LoadObject is not a method of Player. You may have meant LoadInstance.

0

I'm trying to save stats for players when they leave and i have no errors.