Please read title, it explains everything I'm trying to accomplish.
My problem is that I want the beam to be centered on its edge but not on its actual center, help!
game:GetService("RunService").RenderStepped:Connect(function()
local beam = game.workspace:WaitForChild("TargetDirection")
beam.Name = 'TargetDirection'
beam.CanCollide = false
local Target = game.Workspace:FindFirstChild("Lock On!")
local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local ray = Ray.new(Target.CFrame.p, (HumanoidRootPart.CFrame.p - Target.Position).unit)
local AnchorPoint = script:WaitForChild("AnchorPoint")
if (Target.Position - HumanoidRootPart.Position).magnitude < 20 then
beam.BrickColor = BrickColor.new("Lime green")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
beam.Shape = Enum.PartType.Cylinder
beam.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction)* CFrame.Angles(0,math.pi/2,0);
beam.Size = Vector3.new(((Target.Position - HumanoidRootPart.Position) + AnchorPoint.Value).magnitude, 0.05, 0.05);
else
beam.Transparency = 1
end
end)

7 comments
Offset it in the z-axis by half its length. Otherwise, the beam will be centered exactly on the player.
@XAXA Size or Position?
Its CFrame.
@XAXA the position of the CFrame or the Rotation of the CFrame?
@XAXA Also, dividing the Z Axis's position does not achieve my desired result sadly, do you have any other ideas?
Have you tried using
FindPartOnRay? http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartOnRay@TheeDeathCaster I have no idea how to use that correctly within what the wiki gives me.