Hi! I want to know that how do i save something in PlayerGui when player removing?
I want to save children in the
PlayerGui.Test.Queue
So I tried
game:GetService("Players").PlayerRemoving:Connect(function(Player)
local TargetGui = Player.PlayerGui.Test.Queue
local DataToSave = {}
for i, v in pairs(TargetGui:GetChildren()()) do
if v:IsA("Frame") then
table.insert(DataToSave,v)
end
end
DataStore:SetAsync(Player.UserId.."-Queue",DataToSave)
end)
Yeah, but that’s a GUI in PlayerGUI. The GUI will be destroyed as well and the variable/ table key would return as nil.
I think the best solution to this is to either place the GUI somewhere else than PlayerGui or code something that detects changes inside the GUI so you could clone the GUI and then apply the changes to the clone. Then save the clone.