Game freezing when pressing a ui button hooked to a run service loop

So I’am making a tower defense game where I’m currently making the placement system

So when you press a button the placeholder is supposed to appear and you can drag it around and place it down… The problem is that when you press the button it freezes your game for a solid 5 seconds and your CPU spikes before the placeholder appears.

Placeholder function:

local function createTowerPlaceholder(tower)

	local towerExist = towersFolder:FindFirstChild(tower)
	
	if not towerExist then
		warn("Tower "..tower.." aint a thing")
		return
	end
	
	removePlaceholder()
	towerToSpawn = towerExist:Clone()
	towerToSpawn.Parent = currentPlaceHolders
	
	for i, v in ipairs(towerToSpawn:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Transparency = 0.5
		end
		colorPlaceholder(BrickColor.new("Baby blue"))
	end
	
	
	
end

Activation (the button)

testTowerButton.Activated:Connect(function()

	rotation = 0

	createTowerPlaceholder("Trooper")
	script.select:Play()
end)

Loop for placeholder to follow mouse

runService.RenderStepped:Connect(function()
	
	if towerToSpawn then
		
		local result = mouseRaycast({towerToSpawn, character, currentTowers:GetChildren(), workspace.Main.ClientModels:GetChildren()})
		if result and result.Instance then
			
			if result.Instance.Parent.Name == "PlacementArea" then
				canPlace = true
				colorPlaceholder(BrickColor.new("Baby blue"))
			else
				canPlace = false
				colorPlaceholder(BrickColor.new("Bright red"))
			end
			
			local x = result.Position.X
			local y = result.Position.Y + 1.8 -- chnage later so its for each tower!!!
			local z = result.Position.Z

			local newCframe = CFrame.new(x,y,z) * CFrame.Angles(0, math.rad(rotation), 0)

			if towerToSpawn.PrimaryPart then
				towerToSpawn:SetPrimaryPartCFrame(newCframe)
			else
				warn("No primary part")
			
			end
		end
		
	end
	
end)

why is this?

Only logical explanation with the given info would be that this function lags your game, check it

Or this, but these functions sounds like they are simple but i dont see them so idk if you have something there that lags

I doubt that, its literally just that:

local function removePlaceholder()
	if towerToSpawn then
		towerToSpawn:Destroy()
		towerToSpawn = nil
	end
end

The weird thing is that it worked before, just when I changed the tower model it started freezing…

i guess the problem is in the model then

Yes. It’s so weird. It literally just a mesh r6 rig with a helmet and a cloak 0_0