Offsetting a cframe to go just behind a player depending on look vector?

Hello scripters, I am trying to ray cast a laser to follow a player but just behind so then they can actually run away, how do I do this so it is always behind them no matter what?

What I currently have:

The current way I calculate where to go:

	LaserPart.CFrame =, rayTarget) *,0, -distance / 2)

What I want (The red line is what I have, the black is a demonstration of what I want):


If they stand still do you want them to get hit or do you want it to still fire behind them?

I want them to be hit, so basically I want to give them a chance to run but if still they get hit+

I would probably do something like, target - humanoid.MoveDirection) ...

Multiply that by what I have? That would fling it really far would it not?

You would have to edit the distance variable to be accurate to the new distance, but yes multiply it with what you have
I don’t currently see why it would fling and I hope it doesn’t but you’d have to fill me in on what happens

With just multiplying it I get this as a result,

That seems strange, what is your code?
Is it along the lines of this?

	LaserPart.CFrame =, rayTarget - humanoid.MoveDirection) *,0, -distance / 2)

Perhaps I wasn’t as specific as I should be and that’s what caused the problem

Awesome, now any ideas on how to fix this flickering?


local function castRay(rTarget)

	--print("Target in castRay is set to"..rTarget)

	local laser_Thickness = .5

	local rayOriginPart = Eye
	local rayTargetPart = rTarget

	local origin = rayOriginPart.CFrame.Position
	local rayTarget = rayTargetPart.HumanoidRootPart.CFrame.Position
	local direction = (rayTarget - origin)

	local results = workspace:Raycast(origin, direction, RayCastParameters)

	if not results then
		results = {Position = rayTarget}

	local distance = (results.Position - origin).Magnitude

	LaserPart.Size =,laser_Thickness,distance)

	LaserPart.CFrame =, rayTarget - rTarget.Humanoid.MoveDirection) *,0, -distance / 2)

	--game.ReplicatedStorage.EyeEvent:FireAllClients(origin, rayTarget, distance, LaserPart)

local target

	target = Target

Where is it going when its flickering? For example is it going to (0,100000000,0), to another target, under the map, etc?

As you can see, it is changing even if I am standing still, it shouldn’t be switching target so isn’t that I don’t think.

Are you blacklisting the laser part?


local RayCastParameters =
RayCastParameters.FilterDescendantsInstances = game.Workspace.HappyHome.Home.EyeOfSauron.Eye.Parent:GetChildren()
RayCastParameters.FilterType = Enum.RaycastFilterType.Blacklist

Blacklisting the laser might solve your problem, I think its hitting the laser part and using that distance as the new distance
Once it gets yeeted out of the way it can cast all the way to the character unblocked, which would explain the “alternating” behavior

Why not put a wait(1) in the script before firing the laser. If you want don’t want the laser to jump every second you may be able to Lerp the laser to the next point.
If the player moves it’ll pick up their Position, wait, then lerp to that Position. If the player moves it’ll never catch them. You may need to adjust the wait(1) higher or lower to adjust how close the laser gets though.

Now it doesn’t show so blacklisting I don’t think will work

Pretty sure it’s not just firing lasers. It’s a laser that tracks the human which renders the wait(1) solution useless.

They want the laser to track and follow the player if they are walking, but if the player stops then it catches up and kills them.
My suggestion was to try to make it lag behind their Position with the wait(x), so if they stop the Position of the laser would update and move to their stopped Position.