How to make a part come out of the player and face their looking direction

  1. What do you want to achieve? Keep it simple and clear!

I want to make a lazer come out of the player for an ability, I want the end of the lazer to be humanoidrootparts position, and have the lazer face the direction the humanoidrootpart is.
2. What is the issue? Include screenshots / videos if possible!
the issue is the lazer doesnt face the right direction, nor does the end get positioned at my center, but im mainly focusing on the direction
what happens:

what i want to happen: Untitled

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

ive searched devhub, asked roblox assistant and chatgpt and ive found nothing. the best ive gotten is the lazer facing the opposite direction i want, if i was facing forward it would face left.

current code (stupid part is for welding since touched events dont work with two anchored parts and lazer has cancollide off)

if ability == 'Lazer' then
		local lazer = rs.spawnables.AbilityVisuals.Lazer:Clone()
		lazer.Player.Value = plr
		lazer.Multiplier.Value = multi
		lazer.Parent = workspace

		local character = plr.Character
		local humanoidRootPart = character:WaitForChild("HumanoidRootPart") 

		lazer.CFrame =

		local direction = (character.Head.Position - humanoidRootPart.Position).unit

		lazer.CFrame =, humanoidRootPart.Position + direction)
		local stupidpart ='Part')
		stupidpart.CanCollide = false
		stupidpart.Parent = workspace
		stupidpart.Transparency = 1
		stupidpart.Anchored = true
		stupidpart.Position = humanoidRootPart.Position
		lazer.WeldConstraint.Part0 = lazer
		lazer.WeldConstraint.Part1 = stupidpart

		connection = lazer.Touched:Connect(function(part)
			if part.Name == 'Crop' and part:FindFirstChild('Type') then, part, script.Parent.Multiplier.Value)

		game:GetService('Debris'):AddItem(lazer, 1)
		game:GetService('Debris'):AddItem(stupidpart, 1)

The part is facing forward. I would suggest changing the size of the part (i dont know the dimensions), and switch the X and Y, going from (1,1,5)—>(5,1,1)

Or, you can use a transform

lazer.CFrame = (humanoidRootPart.CFrame * CFrame.Angles(0,math.rad(90),0)):ToWorldSpace(,0,0))

We’re essentially rotating the lazer on the humanoidRootPart, then offsetting it on the X-Axis by half of the lazer’s X size (the longest side)

this solved my issue thank you

1 Like

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