Raycast Placement Rotating Model Wrong

I have a script that lets me click a button that spawns in a tower, but the problem is, it is spawning on its side instead of right side up, and I’m not sure how I would fix this, since nothing I have tried works.

RunService.RenderStepped:Connect(function()
	if towerToSpawn then
		local result = MouseRaycast({towerToSpawn})
		if result and result.Instance then
			local x = result.Position.X
			local y = result.Position.Y + (towerToSpawn.PrimaryPart.Size.Y / 2)
			local z = result.Position.Z

			local cframe = CFrame.new(x,y,z)
			towerToSpawn:SetPrimaryPartCFrame(cframe)
		end
	end
end)

image

You could use the tower’s PivotPoint and adjust it until it is upright.

Can you give me an example of how I would implement this into my script?