how would i go about saving elements inside of scrolling frame?
Iterate over the children of the ScrollingFrame instance and serialize each child into a format which can be stored inside of a DataStore, for example.
local players = game:GetService("Players")
local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("SFItems")
local sf = nil --path to scrollingframe
local function serializeFrame()
local tabularizedFrame = {}
for _, child in ipairs(sf:GetChildren()) do
if child:IsA("TextLabel") then --presume the children of the frame are text labels
table.insert(tabularizedFrame, {child.Name, child.Text}) --store relevant information of the children here (in this case the text label's name and text)
end
end
return tabularizedFrame
end
local function onPlayerAdded(player)
local data = ds:GetAsync(player.UserId) --load serialized data here
--deserialize data here
end
local function onPlayerRemoving(player)
local data = serializeFrame() --serialize data here
ds:SetAsync(player.UserId, data) --store serialized data
end
players.PlayerAdded:Connect(onPlayerAdded)
players.PlayerRemoving:Connect(onPlayerRemoving)
i mean like if a frame is added inside the scrolling frame while in game and the player leave and rejoin the frame will still be there
You need to add a join event so that when a player joins check its datastore and checl if that frame was there before or not
I thought about that but I don’t know to do it