How to Inverse the Raycast

Hello guys, I’m currently making a realistic fps game and now I got a problem with RayCasting
‘’’
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = Filter

	local RayCastResult = workspace:Raycast(DrawBackStart.Position, Direction, Params)
	
	if RayCastResult then
		print(RayCastResult.Distance)
		DrawBackOffset = CFrame.new(0,0,RayCastResult.Distance)
	else
		DrawBackOffset = CFrame.new()
	end

‘’’
this code works completely fine but the output is 9 to 0 but in order to make the weapon draw back system I need the output to be 0 to 9, I already try to reverse it but it didn’t work quite well here’s the problem in game

uhh

--...etc
if RayCastResult then
	DrawBackOffset = CFrame.new(0,0, Direction.Magnitude - RayCastResult.Distance)
--...etc
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.