Using raycasting to check for terrain material

So I have a building system that allows you to build on Roblox terrain, but I don’t want players to build on terrain water. Is there a way to check the material of the terrain the player is trying to build on? This is what I have so far (not the full code just the relevant parts):

local function meetsPlacingRequirements(hit)
	if hit then --in this case, hit == workspace.Terrain
		--insert check for terrain material
	end
end

local function handleRenderStepped()
	if placingStructure and clientStructure then
		local mouseRay = mouse.UnitRay;
		local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000);
		local ignoreList = {clientStructure, character};
		local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList);
		
		if meetsPlacingRequirements(hit) then
			setPlacingStatus(true);
		else
			setPlacingStatus(false);
		end
	end
end

According to the developer hub, :FindPartOnRayWithIgnoreList returns the material as its fourth return value, so you’ll need to add variables for surface normal and material after hit and position.

local hit, position, normal, material = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)

:FindPartsOnRayWithIgnoreList is deprecated though. It’s recommended to use :RayCast instead.