I'm making an FPS Framework and i'm trying to make a part move along a ray. I know how to make the ray and a part that goes across the entire ray like in the wiki tutorial for "raycasting a laser gun". I'm trying to make a part the moves across the ray from the beginning, to the end of the ray without it being a straight line/laser. Thanks!

	local look = loadout.current.Muzzle.CFrame.lookVector
	local start = loadout.current.Muzzle.CFrame.p
	
	local distance = (position - start).magnitude
	local bullet = Instance.new("Part", game.Workspace)
	bullet.Name = "bullet"
	bullet.Material = "Neon"
	bullet.FormFactor = "Custom"
	bullet.Anchored = true
	bullet.CanCollide = false
	bullet.Transparency = 0.5
	bullet.BrickColor = BrickColor.new("Really red")
	bullet.Reflectance = 0.4
	bullet.Size = Vector3.new(0.2, 0.2, distance)
	bullet.CFrame = CFrame.new(position, start) * CFrame.new(0, 0, -distance/2)

4 comments

2

You don't even need a ray, you just need a start point and an end point. Look up tweening.

0

Try using bezier curves to make a 3D line, then make that part go through that line

0

^percil, if you read it, they said w i t h o u t it being a straight line

0

Made a typo, meant it to say just a laser. Sorry.