I want to get one of the attachments for a beam to be on the exact position that my ray is hitting. I have tried the following script but I have learned that an attachment position is relevant to the part it is a child of so now I have no idea how to position it at the ray hit position while it is also relative to the hit part’s position.
I have tried to get the position of the ray hit position by doing some math but I cannot figure it out honestly.
Can anyone give some guidance on this who has made beams with guns before?
function CreateTracer(plr,muzzleVelocity,Dist,pos,Host)
-- pos = raycast.Position
--Host = raycast.Instance
local beam = script.Parent.Beam:Clone()
beam.Parent = game.Workspace
local HostAttachment = Instance.new("Attachment",Host)
local SenderAttachment = Instance.new("Attachment",gun.Tip)
HostAttachment.Position = pos
beam.Attachment0 = SenderAttachment
beam.Attachment1 = HostAttachment