How can i find the "frictional force" vector of a surface

i’m doing a custom character controller and i’m having an issue with it sliding down slopes/terrain,the best solution i could think of was to add a frictional force to the character, and that works just fine, but i don’t know how to find the frictional force direction based on the floor’s normal vector.
image
image

found the solution

local function GetFrictionVector(vec)
	if vec.Magnitude == 0 then error("Vector has no magnitude") end
	local floorAngle = math.acos(vec:Dot(Vector3.new(0,1,0)))
	if vec == Vector3.new(0, 1, 0) or vec == Vector3.new(0, -1, 0) then
		return Vector3.new(1, 0, 0)
	else
		local a = Vector3.new(0,1,0):Cross(Vector3.new(vec.Z, 0, -vec.X))
		local fVector = (CFrame.new(Vector3.new(),a) * CFrame.Angles(floorAngle,0,0)).LookVector
		return fVector
	end
end