Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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!

01local look = loadout.current.Muzzle.CFrame.lookVector
02local start = loadout.current.Muzzle.CFrame.p
03 
04local distance = (position - start).magnitude
05local bullet = Instance.new("Part", game.Workspace)
06bullet.Name = "bullet"
07bullet.Material = "Neon"
08bullet.FormFactor = "Custom"
09bullet.Anchored = true
10bullet.CanCollide = false
11bullet.Transparency = 0.5
12bullet.BrickColor = BrickColor.new("Really red")
13bullet.Reflectance = 0.4
14bullet.Size = Vector3.new(0.2, 0.2, distance)
15bullet.CFrame = CFrame.new(position, start) * CFrame.new(0, 0, -distance/2)
2
You don't even need a ray, you just need a start point and an end point. Look up tweening. Perci1 4988 — 7y
0
Try using bezier curves to make a 3D line, then make that part go through that line saSlol2436 716 — 7y
0
^percil, if you read it, they said w i t h o u t it being a straight line abnotaddable 920 — 7y
0
Made a typo, meant it to say just a laser. Sorry. The_MRAP 4 — 7y

Answer this question