Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the 'FindPartOnRayWithIgnoreList' method working?

This fires a ray from a brick and creates the parts called 'bOOm' when the ray hits an object.. the parts are created however when they are, the ray is obstructed by the bOOm parts. I was told to use the 'FindPartOnRayWithIgnoreList' so I tried but it's not working.

I'm probably using it incorrectly so please help.

This is what it looks like: Raycast

while wait() do

    local bOOm = Instance.new("Part")
    bOOm.BrickColor = BrickColor.new("Bright red")
    bOOm.FormFactor = "Custom"
    bOOm.Material = "Neon"
    bOOm.Transparency = 0.25
    bOOm.Anchored = false
    bOOm.CanCollide = false
    bOOm.Name = "bOOm"
    local ray = Ray.new(script.Parent.CFrame.p,  script.Parent.CFrame.lookVector * 300)

    local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent, bOOm}) -- Problem is here

        bOOm.Parent = workspace

        local beam = Instance.new("Part", workspace)
        beam.BrickColor = BrickColor.new("Bright red")
        beam.FormFactor = "Custom"
        beam.Material = "Neon"
        beam.Transparency = 0.25
        beam.Anchored = true
        beam.CanCollide = false

        local distance = (script.Parent.CFrame.p - endPoint).magnitude
        beam.Size = Vector3.new(0.3, 0.3, distance)
        beam.CFrame = CFrame.new(script.Parent.CFrame.p, endPoint) * CFrame.new(0, 0, -distance / 2)

        bOOm.Size = Vector3.new(1, 1, 1)
        bOOm.CFrame = CFrame.new(endPoint)

        print(part)
        game:GetService("Debris"):AddItem(beam, 0.1)
        game:GetService("Debris"):AddItem(bOOm, 0.4)
end

1 comment

0

The first error i see is in the Ray.new. After you put the origin position you must then take the new position and subtract it from the old position. Then put .unit * 300.

1 answer

✓ Accepted answer

The problem is that multiple bOOm parts are being created, but you are only keeping track of one. The ray is obstructed by the old parts. The easiest solution would probably be to create a folder in the workspace, replace line 15 with this:

bOOm.Parent = workspace.Folder -- Replace 'Folder' with the name of the folder.

and change line 13 to this:

local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent, workspace.Folder})

1 comment

0

It worked, thanks man.

This discussion is preserved as it was. New answers, comments, and votes are closed.