Hi, I'm new to raycasting and I'm using the base script from the wiki but instead im making the origin a part that fires it with a loop.
I managed to get the laser beam firing from the part, but it's not facing forward and the position is off. I'm not too good at CFraming either so if someone could give an explanation that would be appreciated.
Here's the ServerScript in the part:
local head = script.Parent local ignore = game.Workspace.Windows:GetChildren() while true do local ray = Ray.new(head.CFrame.p, (head.CFrame.p) + Vector3.new(0, 0, 100)) local part, position = workspace:FindPartOnRayWithIgnoreList(ray, ignore, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("Institutional white") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0.5 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (head.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3, 0.3, 100) beam.CFrame = CFrame.new(head.CFrame.p, position) * CFrame.new(0, 0, 0) game:GetService("Debris"):AddItem(beam, 0.1) wait(0.5) end