I want to make a save script that saves the leaderboard stats and the tool they have but im not sure where to start
Try this:
game.Players.PlayerRemoving:connect(function(player) if player:FindFirstChild("leaderstats") then player:SaveNumber(scoreKey, player.leaderstats.Score.Value) end end)
Hope it helps :)
game.Players.PlayerRemoving:connect(function(p) p:WaitFoDataReady() local stats = player.FindFirstChild("leaderstats") if not stats then return end player:Savenumber("leaderstats",leaderstats.value)--save leaderstats local plrsg = player.StarterGear:GetChildren() local plrbp = player.Backpack:GetChildren() p:SaveInstance("Tools",plrsg)--save tools in StarterGui p:SaveInstance("Tools1",plrbp) end)
then if u want to load them do this
game.Players.PlayerAdded:connect(function(p) p:WaitForDataReady() local ls = Instance.new("IntValue", p) ls.Name = "leaderstats" if SavedLevel == 0 then SavedLevel = 1 end ls.Value = Savedls local playersg = p:LoadInstance("Tools") playersg.Parent = p.StarterGear local playerbp = p:LoadInstance("Tools1") playerbp.Parent = p.BackPack end)
Hope this helps :D I havent checked it but it should be alright there maybe some minor mistakes plz ignore them i m not so particular at scripting i let the program search mistakes if the leadersstats dont save then save each leaderstat differently for eg:- if its level then do this
game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() local stats = player:FindFirstChild("leaderstats") if not stats then return end local level = stats:FindFirstChild("Level") if not level then return end player:SaveNumber("Level", level.Value) end) -- and load them game.Players.PlayerAdded:connect(function(p) p:WaitForDataReady() local ls = Instance.new("IntValue", p) ls.Name = "leaderstats" local lev = Instance.new("IntValue", ls) lev.Name = "Level" SavedLevel = p:LoadNumber("Level") if SavedLevel == 0 then SavedLevel = 1 end lev.Value = SavedLevel end)
if u save them differently then i m sure it will save them properly but if the tools dont save then i dont have any idea how to do it.