I have a minor problem with saving my tycoon

I’ve made a script that saves parts (kinda) for my tycoon, i want it to save parts from “Purchased” folder, this is what tycoon normally looks like without the script being enabled (it doenst save)

and this is what it looks like when script is enabled and saves my parts

I have no idea why that happens in my script, tried doing research but nothing didnt find anything related to this (it also make a random part seen in the left down corner and idk why)

local dts = game:GetService("DataStoreService")
local partdata = dts:GetDataStore("TycoonData")
local plrs = nil
local savingtable = {}

game.Players.PlayerAdded:Connect(function(plr)
	plrs = plr
	
	for _, event in workspace.Tycoons:GetDescendants() do
		if event:IsA("BindableEvent") and event.Name == "ClaimTycoon" then
			event.Event:Connect(function()
				local model = event.Parent.Parent.Parent 
				
				local data
				local success, errormsg = pcall(function()
					data = partdata:GetAsync(plr.UserId)
				end)
				if success and data ~= nil then
					for i, v in pairs(data) do
						local part = Instance.new("Part", model.Purchases)
						part.Name = v.Name
						part.Anchored = true
						part.Position = Vector3.new(v["PosX"], v["PosY"], v["PosZ"])
						part.Size = Vector3.new(v["SizeX"], v["SizeY"], v["SizeZ"])
						part.Color = Color3.fromRGB(v["ColorR"]*255, v["ColorG"]*255, v["ColorB"]*255)
						part.Material = v["Material"]
					end
				end
			end)
			
		elseif event:IsA("BindableEvent") and event.Name == "Save" then
			event.Event:Connect(function()
				table.clear(savingtable)
				
				local model = event.Parent.Parent.Parent 
				
				for i, v in pairs(model:FindFirstChild("Purchases"):GetDescendants()) do
					if v:IsA("BasePart") then
						local NewTable = {
							PosX = v.Position.X, 
							PosY = v.Position.Y, 
							PosZ = v.Position.Z,
							SizeX = v.Size.X,
							SizeY = v.Size.Y,
							SizeZ = v.Size.Z,
							ColorR = v.Color.R,
							ColorG = v.Color.G,
							ColorB = v.Color.B,
							Material = v.Material.Name
						}
						table.insert(savingtable, NewTable)
					end
				end
			end)
		end
	end
end)

game.Players.PlayerRemoving:Connect(function()
	partdata:SetAsync(plrs.UserId, savingtable)
end)

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

from what i can see you are only saving the position of the parts, not the orientation.
also, when using the instance function with a part it default adds that studded apperance to it.

Instead of saving the position of the part, save its CFrame

also, im not sure why you are saving each individual value of the position, size and color individually.

you could just do

local NewTable = {
 CFrame = v.CFrame,
 Size = v.Size,
 Color = v.Color
}

and of course update these values with

part.CFrame = v["CFrame"] -- updates position AND orientation
part.Size = v["Size"]
part.Color = v["Color"]
part.BottomSurface = Enum.SurfaceType.Smooth
part.TopSurface = Enum.SurfaceType.Smooth -- removes studs on the parts

hmm it didn’t work, the tycoon just refused to load entirely and i got this error whilst trying to leave game:

thats my bad, i dont work with datastores much and it appears your original system of saving data would have worked. In your case, instead of using cframes i would recommend saving the position and orientation values and applying them. basically, the system you had before but with orientation as well. and the

part.BottomSurface = Enum.SurfaceType.Smooth
part.TopSurface = Enum.SurfaceType.Smooth -- removes studs on the parts

should still be fine in the script

yeah, i guess it did kind of fixed this, i mean it works perfectly, but only for parts, not unions or meshes, also assemblyangularvelocity doesnt seem to save and idk why lol, do you have any idea why?

velocity isnt saving, well because, your not saving it. you would have to add that to the data store. as for unions and meshes, its not saving because you script assumes its a part.
unions and meshes are unique, and using a basepart to create them fails that.

ok, what can i do for script to not ignore unions or meshes, wedges, cylinders…?

unions and meshes are unique in the sense that each mesh and union is different.
you would need a system that have an index of avaliable meshes and unions, figures out which union or mesh it has, and properly clones that.
as for wedges and cylinders use the part.Shape property.

thats the extent of input i believe i am going to give on how to make said system, as one thing i’ve noticed here is a lack of understanding on how the roblox instances and properties work, and to create such a system would require you to understand these properties. meaning creating this system unguided here could help you understand such properties

as such, i believe you should refer to roblox docs on unions, meshparts, and parts for more information on what they contain, and you can then save that information to a datastore.

tl;dr: you need to provide unique information per part to the datastore

thanks you, im gonna try to make this work, this was gonna be so much harder than i thought lol