Spawn Point Not Spawning Player In The Proper Area if theres a part of the script updated!

When I change up a script, the spawn points within the game stop functioning.

For example:
When I have the first script (below), the spawn point works and functions as expected. But when I change up the script (below), the spawn point does not function as intended. I have summed this up in a video below!



Non-Changed

local spawnArea = workspace.SpawnZoneA1 
local partFolder = game.ReplicatedStorage.AreaBlocks.Area1Blocks 

--//


local function hasCollision(position)
	local region = Region3.new(position - Vector3.new(0.5, 0.5, 0.5), position + Vector3.new(0.5, 0.5, 0.5))
	local ignoreList = {spawnArea}

	local parts = workspace:FindPartsInRegion3WithIgnoreList(region, ignoreList)
	return #parts > 0
end

local function spawnParts()
	local partTemplate = partFolder:FindFirstChild("A1Dirt") 
	if not partTemplate then
		warn("A1Dirt not found in Area1Blocks!")
		return
	end

	local partSize = partTemplate.Size
	local spawnSize = spawnArea.Size

	local partsToSpawnX = math.floor(spawnSize.x / partSize.x)
	local partsToSpawnY = math.floor(spawnSize.y / partSize.y)
	local partsToSpawnZ = math.floor(spawnSize.z / partSize.z)

	local startX = spawnArea.Position.x - spawnSize.x / 2 + partSize.x / 2
	local startY = spawnArea.Position.y - spawnSize.y / 2 + partSize.y / 2
	local startZ = spawnArea.Position.z - spawnSize.z / 2 + partSize.z / 2

	local function isValidPosition(position)
		return not hasCollision(position)
	end

	local function spawnPartAtPosition(position)
		local newPart = partTemplate:Clone()
		newPart.Parent = workspace
		newPart.CFrame = CFrame.new(position)
	end

	for i = 1, partsToSpawnX do
		for j = 1, partsToSpawnY do
			for k = 1, partsToSpawnZ do
				local position = Vector3.new(
					startX + (i - 1) * partSize.x,
					startY + (j - 1) * partSize.y,
					startZ + (k - 1) * partSize.z
				)

				if isValidPosition(position) then
					spawnPartAtPosition(position)
				end
			end
		end
	end
end```


spawnParts()

**Changed**
```--// Spawn Settings
local spawnArea = workspace.SpawnZoneA1 
local partFolder = game.ReplicatedStorage.AreaBlocks.Area1Blocks 
--//

local function hasCollision(position)
	local region = Region3.new(position - Vector3.new(0.5, 0.5, 0.5), position + Vector3.new(0.5, 0.5, 0.5))
	local ignoreList = {spawnArea}

	local parts = workspace:FindPartsInRegion3WithIgnoreList(region, ignoreList)
	return #parts > 0
end


local function spawnParts()

	for _, part in ipairs(workspace:GetChildren()) do
		if part:IsA("Part") and part.Name ~= "Baseplate" then
			part:Destroy()
		end
	end

	local partTemplate = partFolder:FindFirstChild("A1Dirt")
	if not partTemplate then
		warn("A1Dirt not found in Area1Blocks!")
		return
	end

	local partSize = partTemplate.Size
	local spawnSize = spawnArea.Size

	local partsToSpawnX = math.floor(spawnSize.x / partSize.x)
	local partsToSpawnY = math.floor(spawnSize.y / partSize.y)
	local partsToSpawnZ = math.floor(spawnSize.z / partSize.z)

	local startX = spawnArea.Position.x - spawnSize.x / 2 + partSize.x / 2
	local startY = spawnArea.Position.y - spawnSize.y / 2 + partSize.y / 2
	local startZ = spawnArea.Position.z - spawnSize.z / 2 + partSize.z / 2

	local function isValidPosition(position)
		return not hasCollision(position)
	end

	local function spawnPartAtPosition(position)
		local newPart = partTemplate:Clone()
		newPart.Parent = workspace
		newPart.CFrame = CFrame.new(position)
	end

	for i = 1, partsToSpawnX do
		for j = 1, partsToSpawnY do
			for k = 1, partsToSpawnZ do
				local position = Vector3.new(
					startX + (i - 1) * partSize.x,
					startY + (j - 1) * partSize.y,
					startZ + (k - 1) * partSize.z
				)

				if isValidPosition(position) then
					spawnPartAtPosition(position)
				end
			end
		end
	end
end


spawnParts() 
while wait(2700) do  
	spawnParts()
end ```

------------------------

If you could help out anything would be appriciated.


[copy_5DA1AC5F-06FC-4ABF-B573-73F27EAB9D87|video](upload://tFdb3GySMbRt0m1Btz8qMo7ne9Y.mov)

Also sorry for the scripts not being embed my bad!

This’ll be a pain to read without formatting…

Could you edit your message so the code is inside two rows of triple backquotes?
`x3

`x3

Its been fixed thanks for the help!