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

0

Offset it in the z-axis by half its length. Otherwise, the beam will be centered exactly on the player.

0

@XAXA Size or Position?

0

Its CFrame.

0

@XAXA the position of the CFrame or the Rotation of the CFrame?

0

@XAXA Also, dividing the Z Axis's position does not achieve my desired result sadly, do you have any other ideas?

0

@TheeDeathCaster I have no idea how to use that correctly within what the wiki gives me.