Weapons Beam floating in mid air

So this is happening to all of our blasters and this has never happened before, We scripted the weapons if they Hit Part the beam would disappear and also for distance. But now they are just floating in mid air.



Could you show line numbers for the script source code

Assuming your error is happening at if HitPart.Name ~= “Block” then,

Make sure to verify that HitPart exists before checking for the Name property with

if HitPart then
    -- the rest of your code
end

-- Alternatively...

if not HitPart return end

-- the rest of your code
1 Like

Everything works and all but if you shoot it in mid air it freezes and dose not destroy only if It touches.

It’s because HitPart is the ray result for whatever it touches in It’s direction, if its nil then the code will error as it found nothing to touch.

Adding a simple if HitPart and HitPart.Name ~= "Block" then to replace the errored line will fix it

1 Like