I made like a million errors so can someone explain them, so it doesn't happen again and then help me fix them. This script is made to save furniture and has other features too.
local Houses = workspace.Houses local AvailableHouses = Houses.AvailibleHouses local UsedHouses = Houses.UsedHouses local DataStoreServide = game:GetService("DataStoreService") local PlayerCarsDataStore = DataStoreServide:GetDataStore("ChosenCar") local CurrentFurnature = DataStoreServide:GetDataStore("CurrentFurnature") local FurnatureAnchor = DataStoreServide:GetDataStore("FurnatureAnchor") local DefaultCar = "Sedan (red)" game.Players.PlayerAdded:Connect(function(Player) local ChosenHouse = AvailableHouses:FindFirstChildOfClass("Folder") ChosenHouse.Name = Player.Name ChosenHouse.Parent = UsedHouses local Charachter = workspace:WaitForChild(Player.Name) Charachter:MoveTo(ChosenHouse.Spawn.Position) local playerFurnature = CurrentFurnature:GetAsync(Player.UserId) or nil if playerFurnature ~= nil then playerFurnature = game:GetService("HttpService"):JSONDecode(playerFurnature) else playerFurnature = nil end local furnatureModel = Instance.new("Model", ChosenHouse.Furnature) furnatureModel.Name = "FurnatureGroup" if playerFurnature ~= nil then for key, value in pairs(playerFurnature) do local createdItem = game.ReplicatedStorage:WaitForChild(key):Clone() createdItem.Parent = furnatureModel createdItem.CFrame = value end local anchorValues = FurnatureAnchor:GetAsync(Player.UserId) or nil if anchorValues ~= nil then local createdAnchor = Instance.new("Part", furnatureModel) createdAnchor.Anchored = true createdAnchor.Name = "Anchor" createdAnchor.Position = anchorValues.Position createdAnchor.Orientation = anchorValues.Orientation createdAnchor.Size = anchorValues.Size createdAnchor.Shape = Enum.PartType.Ball createdAnchor.Transparency = 1 createdAnchor.CastShadow = false createdAnchor.CanCollide = false furnatureModel.PrimaryPart = createdAnchor furnatureModel:MoveTo(ChosenHouse.FurnaturePosition.Position) furnatureModel:PivotTo(ChosenHouse.FurnaturePosition.CFrame) else local createdAnchor = ChosenHouse.FurnaturePosition:Clone() createdAnchor.Name = "Anchor" createdAnchor.Parent = furnatureModel furnatureModel.PrimaryPart = createdAnchor furnatureModel:MoveTo(ChosenHouse.FurnaturePosition.Position) furnatureModel:PivotTo(ChosenHouse.FurnaturePosition.CFrame) end end game.ReplicatedStorage.Change.OnServerEvent:Connect(function(player, part, color) if part == "Wall" then for i, part in pairs(ChosenHouse.Wall:GetChildren()) do part.Color = color wait() end else for i, part in pairs(ChosenHouse.Trim:GetChildren()) do part.Color = color wait() end end end) Player.CharacterAdded:Connect(function(Char) Char:MoveTo(ChosenHouse.Spawn.Position) end) game.Players.PlayerRemoving:Connect(function(player) local FG = ChosenHouse.Furnature.FurnatureGroup print("A") local Anchor = FG:WaitForChild("Anchor") --Stops working here, before i added wait for child, it was find first chind and it would resault in an error print("A") local AnchorProperties = { Position = nil, Orientation = nil, Size = nil, } print("A") AnchorProperties.Position = Anchor.Position print("A") AnchorProperties.Size = Anchor.Size print("A") AnchorProperties.Orientation = Anchor.Orientation print("A") script.Parent.HouseSave.Event:Fire(Player.UserId, AnchorProperties) print("A") Anchor:Destroy() print("A") local SavingItems = {} print("B") for i, item in pairs(FG:GetChildren()) do print(tostring(item.Value.Value)) SavingItems[item.Name] = tostring(item.Value.Value) print("ItemSaved") end print("All items saved") print(SavingItems) local EncodedSavedItems = game:GetService("HttpService"):JSONEncode(SavingItems) print(EncodedSavedItems) CurrentFurnature:SetAsync(Player.UserId, EncodedSavedItems) if player == Player then ChosenHouse.Name = "OpenHouse" ChosenHouse.Parent = AvailableHouses end end) game.ReplicatedStorage.SpawnCar.OnServerEvent:Connect(function() local CarName = PlayerCarsDataStore:GetAsync(Player.UserId) or DefaultCar local Car = game.ReplicatedStorage.Cars:FindFirstChild(CarName):Clone() Car.Parent = workspace Car:MoveTo(ChosenHouse.CarSpawn.Position) end) end)