Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a Save script?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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

0
this script save the leaderboard score but not the tool they have but nice try though Revenant101 25 — 10y
0
Okay i surely know how to do it i'm getting back to you soon! :) Pixelatee 0 — 10y
0
ok Revenant101 25 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
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.

0
I wanna store the tools and the leaderstats Revenant101 25 — 10y

Answer this question