Make a part move along a raycast?
Asked by
7 years ago Edited 7 years ago
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!
01 | local look = loadout.current.Muzzle.CFrame.lookVector |
02 | local start = loadout.current.Muzzle.CFrame.p |
04 | local distance = (position - start).magnitude |
05 | local bullet = Instance.new( "Part" , game.Workspace) |
07 | bullet.Material = "Neon" |
08 | bullet.FormFactor = "Custom" |
10 | bullet.CanCollide = false |
11 | bullet.Transparency = 0.5 |
12 | bullet.BrickColor = BrickColor.new( "Really red" ) |
13 | bullet.Reflectance = 0.4 |
14 | bullet.Size = Vector 3. new( 0.2 , 0.2 , distance) |
15 | bullet.CFrame = CFrame.new(position, start) * CFrame.new( 0 , 0 , -distance/ 2 ) |