I'm trying to make a part travel along a ray, I know how to make the ray, and I can make a part that goes along the entire ray like a regular raycast gun. But I'm trying to make a part that starts at the beginning of the ray, and moves along the ray till the end of the ray without appearing as a line.
local look = pilot.Character:findFirstChild("Shuttle").Cannon.CFrame.lookVector local start = pilot.Character:findFirstChild("Shuttle").Cannon.CFrame.p local ray = Ray.new(start,look.unit*300) local ignore = {pilot.Character:findFirstChild("Shuttle"),pilot.Character} local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignore) local distance = (position - start).magnitude local RB = Instance.new("Part", game.Workspace) RB.Name = "Laser" RB.Material = "SmoothPlastic" RB.FormFactor = "Custom" RB.TopSurface = "Smooth" RB.BottomSurface = "Smooth" RB.Anchored = true RB.CanCollide = false RB.Transparency = 0.5 RB.BrickColor = BrickColor.new("Really blue") RB.Reflectance = 0.4 RB.Size = Vector3.new(0.2, 0.2, distance) RB.CFrame = CFrame.new(position, start) * CFrame.new(0, 0, -distance/2)
But if I change the distance to a number in the line below, then the part just spawns at the end of the ray instead of spawning at the beginning and traveling along the ray.
RB.Size = Vector3.new(0.2, 0.2, distance)