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

Save and Load Boolean Value?

I need 2 scripts. One to save the boolean when someone leaves, and one to load the boolean when they join. The boolean is in a textbutton in a screengui in the startergui. Script for when someone joins

game.Players.PlayerAdded:connect(function(p) -- Try. try.
    local bought = Player.playergui.Inventory.Inventory.Frame.Item.HasBought.Value
    if p:WaitForDataReady() then
        local loaded = p:SaveBoolean(bought)
        bought = loaded 
print("Loaded")
    end
end)


Any halp ples

2 comments

0

Well one issue I see, is "Player" is referenced when it does not exist. "p" is the reference for a player. Consider changing that.

0

Also: You do not need 2 seperate scripts, you only need 2 functions on the same script

1 answer

Well, I'm guessing you are attempting to save this permanently, so that the save triggers when the player comes back.

This can be done with DataPersistence or DataStore

Let me explain the differences before I expand:

DataPersistence saves any instance to a player that can be loaded on only THAT game. Information for DataPersistence: wiki.roblox.com/index.php?title=Data_persistence

DataStore can be used to save information across many different games, but only works in a table format. Information for DataStore: wiki.roblox.com/index.php?title=Data_store Hope this helped. Please feel free to comment for additional help.

1 comment

0

Well my links dont seem to work =/

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