Hi! :D I have a tool that will send a beam from its tip called BeamPart to the mouse.Hit . I don't want to create an additional part to attach the beam to it, I want to use the Attachment.Position property. Both attachments and the beam are parented to BeamPart, one attachment should permanently stay on the BeamPart, and the other one's Position property should change to match the mouse.Hit . But I am not that good with math, especially vector math, so none of my solutions worked. Here's my code:
- BeamPart
- Beam
- tarAtt -- The moving attachment
- stAtt -- The stationary attachment
local pl = game.Players.LocalPlayer
local mouse = pl:GetMouse()
local tool = script.Parent
enabled = true
if enabled then
local function move()
tool.BeamPart.tarAtt.CFrame = CFrame.new(Vector3.new(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)):ToObjectSpace(tool.BeamPart.CFrame)
end
mouse.Move:connect(move)
end

2 comments
Thanks! This is a great answer, but in my question I asked if the beam could be done without a part, using the Attachment's Position property. Is your way to do this (Adding a part) more efficient or was there another reason to do it that way, or did you just misread?
just change to attachements position to mouse.hit.p