How would i make multiple raycasts at different angles

I raycasts fire from the players root to the mouse, but i would need to make 2 others that will have a rotational offset to the right and left at an angle sort of like:

What ive tried so far

for i=1,3 do
		local params = RaycastParams.new()
		params.FilterDescendantsInstances = {dump,char}
		params.FilterType = Enum.RaycastFilterType.Blacklist
		
		local direction
		if i == 1 then
			direction = (CFrame.new(humRoot.Position, mousePos) * CFrame.Angles(0,math.rad(-15),0)).Position
		elseif i == 2 then
			direction = CFrame.new(humRoot.Position, mousePos).LookVector * 60 -- 60 is the speed
		elseif i == 3 then
			direction = (CFrame.new(humRoot.Position, mousePos) * CFrame.Angles(0,math.rad(15),0)).Position
		end
		
		local result = workspace:Raycast(humRoot.Position,direction * , params)
		if result then
			print(result.Instance)
		end
	end

Any help will be apriciated, thanks

Your picture implies that the ends of these rays will line up diagonally, is that what you intended?

Correct me if I did anything wrong…

for i=1,3 do
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {dump,char}
	params.FilterType = Enum.RaycastFilterType.Blacklist
		
	local rotation = 15 * i - 30 --// Little formula to remove the if i == 1, i == 2, etc. drama
	local StraightCFrame = CFrame.new(humRoot.Position, mousePos) --// In your drawing, the middle line.

	local direction = (StraightCFrame * CFrame.Angles(0,math.rad(rotation),0)).LookVector --// The direction depending on the rotation variable.

	--// What's happening here: 
	--// we are getting the CFrame which is 'looking' at the mouse position
	--// Which we call StraightCFrame
	--// We then rotate this accordingly
	--// Then finally we get the LookVector of the whole thing.
	
	local result = workspace:Raycast(humRoot.Position,direction * dontforgetthis, params)
	if result then
		print(result.Instance)
	end
end
3 Likes