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!

    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)
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