Checking if raycast is in part

how would I check if my raycast is inside a part, so I can make the player unable to place something:

if RayCastResult ~= nil then
						if (RayCastResult.Instance:IsA("BasePart") or RayCastResult.Name:lower() == "baseplate") and (HumanoidRootPart.Position - clientTower.HitBox.Position).Magnitude < maxPlacingDistance then
							OkToPlace = true
							
							if newHighlight.FillColor ~= Color3.fromRGB(91, 255, 79) then
								newHighlight.FillColor = Color3.fromRGB(91, 255, 79)

								newHighlight2.FillColor = Color3.fromRGB(91, 255, 79)
							end
						else
							OkToPlace = false
							
							if newHighlight.FillColor ~= Color3.fromRGB(255, 74, 74) then
								newHighlight.FillColor = Color3.fromRGB(255, 74, 74)
								
								newHighlight2.FillColor = Color3.fromRGB(255, 74, 74)
							end
						end
						
						local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0) 
						local newCFrame = CFrame.new(RayCastResult.Position.X, RayCastResult.Position.Y + yBuildingOffSet, RayCastResult.Position.Z)
						
						clientTower.HitBox.CFrame = newCFrame * newAnglesCFrame 
					end

Check the Search tool with a term like ‘grid placement’. There are a lot of building game type posts that use this system with many posts and solutions to issues like yours.