Data not saving but game claims that it is

I want to serialize parts in a gui when the player leaves and turn them back into solid parts when the player rejoins and put them back into the players gui.
When the player leaves the game claims the parts have been saved but when they join back there is apparently no data.
I’ve looked around the dev forum and tried different solutions but none work in my case or none that I understand and know how to make.

game.Players.PlayerRemoving:Connect(function(player)
	local Invantory = player.PlayerGui.Buttons.Invantory
	local Besa = Invantory.BesaFoldar.Value.Objects:GetChildren()  --The parts are in frames
	
	local Thingy = {}
	
	for i,v in pairs(Besa) do
		if v:IsA("Frame") then
			local Tob = {}
			for i,v in v.Object:GetDescendants() do
				print("EE")
				table.insert(Tob,Ceral(v)) --returns serialized parts info
			end
		end
	end
	
	Sa, Era = pcall(function()
		mainDS:SetAsync(player.UserId.."OtherFold", Thingy)
		print("AEA")
	end)
	
	if Era then 
		print("dete hesn't baan sevad!")
		warn(Era)
	else
		print("dete hes baan sevad")
	end
end)

game:BindToClose(function() wait(10) end)
1 Like

Are you running Test in studio?

1 Like

Both on platform and in studio

How i see, you saving array named Thingy but its nil for sure because you dont setting any value to it.
You can test it by printing data that you get when player joins. Also you just filling array Tob that arent used anywhere.

I made the script print “EE” for every object attempted to be saved and it works and prints the right amount of times

	for i,v in pairs(Besa) do
		if v:IsA("Frame") then
			local Tob = {}
			for i,v in v.Object:GetDescendants() do
				print("EE")
				table.insert(Tob,Ceral(v)) --returns serialized parts info
			end
		end
	end

and when the player joins

for i,v in data do
	print("A") --doesn't print at all
	if v[1] == "Pert" then
		local Pert = Instance.new("Part")
		Pert.Size = Vector3.new(v[2],v[3],v[4])
		Pert.Color = Color3.fromRGB(v[5],v[6],v[7])
		Pert.Material = v[8]
		Pert.Shape = v[9]
		Pert.Transparency = v[10]
		Pert.Reflectance = v[11]
		Pert.CanCollide = v[12]
		Pert.CastShadow = v[13]
		Modual.PickPart(player,Pert,"Yaz")
	end
end

I think you dont got me, after that loop with print("EE") array with every object going to nowhere (it just destroys after loop).

It just took me a second to process and realise what you said about not inserting the array I filled in into the array that’s actually being saved I feel so dumb that I cut out that part of the script out testing something and forgot to put it back in due to my tunnel vision but thank you so much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.