I am trying to make a laser part come out out of another part (already made in Workspace) based on the positioning of it. It is not a tool, because I don't want the player's mouse to determine where it shoots. I want it to come out from the direction the part in Workspace is pointing to.
I was then led to lookVector after a while of researching. I tried using it like this:
--This is just the section where I create the part
--It's not important, but it's there in case you need it to study my script.
local part = Instance.new("Part", game.Workspace)
part.BrickColor = BrickColor.new("Really red")
part.FormFactor = "Custom"
part.Anchored = true
part.CanCollide = false
part.Material = "Plastic"
part.Transparency = 0.75
--Important Part (I need help on this section)
local base = game.Workspace.Base -- Base part
local distance = 30
part.Size = Vector3.new(0.02, 0.02, distance)
part.CFrame = CFrame.new(base.CFrame.p, base.CFrame.lookVector) * CFrame.new(0, 0, distance/2)
The problem is when I used lookVector like that, it points at a completely different direction and angle from where the base part is pointing to.
If I take out the lookVector part and only have one parameter in the CFrame.new() method, it only comes out in the positive z-direction regardless of where the base part is pointing.
I tried reading up more on lookVector, but the ROBLOX Wiki didn't have enough information for me to learn more about it. Any ideas on how I can do this?

3 comments
Thank you for your response. It helped my script to somewhat work, because it does do it based on the direction of the base part, but now it's always shooting out 90 degrees to the left of the base part. Do you know why it's doing that?
The answer is simple. Your part isn't rotated how you thought it was. Try appending
* CFrame.new(Vector3.new(0,0,0),Vector3.new(1,0,0))to the math and see how that rotates it. Fiddle about with it because I don't understand coordinates.Thanks! That worked! I'll accept your answer now.