The goal is basically to draw a ray, and put an explosion at the end of it. This is my script that I somehow botched.
local ATTE = game.Workspace["AT-TE"] local tool = script.Parent local user tool.Equipped:connect(function (m) user = tool.Parent m.Button1Down:connect(function () local ray = Ray.new(ATTE.Cannon.Cannon.Cannon.CFrame.p, (m.Hit.p - ATTE.Cannon.Cannon.Cannon.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user) local distance = (position - ATTE.Cannon.Cannon.Cannon.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright blue") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, ATTE.Cannon.Cannon.Cannon) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(rayPart, 0.1) end) end)
Anyone see where I faltered? Thanks in advance.