There are 2 scripts, one to save the text when a person leaves
FIRST SCRIPT Loads When a person joins game
BOTH SCRIPTS ARE IN THE WORKSPACE AND ARE REGULAR SCRIPTS
--Things to know about the heirachry - The Thing I want saved is in the StarterGui. -"HasBought" is a boolvalue in the gui thats in the StarterGui - I want to save the value in "HasBought"
local DataStore = game:GetService("DataStoreService"):GetDataStore("Inventory")
game.Players.PlayerAdded:connect(function(player)
local Item = game.StarterGui.Inventory.Inventory.Frame.Item.HasBought
local key = "user-"..player.userId
local SavedText = DataStore:GetAsync(key)
if SavedText then
Item.Value = SavedText
else
local ValuesToSave = {Item.Value}
DataStore:SetAsync(key , ValuesToSave)
end
end)
2ND SCRIPT Saves When a Person Leaves
local DataStore = game:GetService("DataStoreService"):GetDataStore("Inventory")
game.Players.PlayerRemoving:connect(function(player)
local key = "player-"..player.userId
local ValuesToSave = {game.StarterGui.Inventory.Inventory.Frame.Item.HasBought.Value}
DataStore:SetAsync(key , ValuesToSave)
end)
All Help is Appreciated ^.^
