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

How do I make a Save script?

I want to make a save script that saves the leaderboard stats and the tool they have but im not sure where to start

2 answers

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

3 comments

0

this script save the leaderboard score but not the tool they have but nice try though

0

Okay i surely know how to do it i'm getting back to you soon! :)

0

ok

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.

1 comment

0

I wanna store the tools and the leaderstats

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