Two children are nil despite them literally existing?

okay i think what i’m about to show explains everything

function VFX(viewmodel: Model, weapon: Tool)
    local vfxPart: BasePart = viewmodel.Handle:FindFirstChild("VFXPart")
    
    if not vfxPart then return end
    
    local muzzleFlash: ParticleEmitter = vfxPart:FindFirstChild("MuzzleFlash")
    local lightEmitter: PointLight = vfxPart:FindFirstChild("LightEmitter")
    
    if not muzzleFlash or not lightEmitter then
        warn("Muzzle flash or light emitter does not exist!")
        print(muzzleFlash, lightEmitter)
        return
    end
    
    local ammoType: StringValue = weapon:FindFirstChild("AmmoType")
    
    if not ammoType then return end
    
    if ammoType.Value == "NRG" then
        muzzleFlash.Color = Color3.fromRGB(101, 147, 255) -- Blue
    else
        muzzleFlash.Color = Color3.fromRGB(255, 255, 0) -- Yellow
    end
    
    muzzleFlash:Emit(1)
    
    coroutine.wrap(function()
        lightEmitter.Enabled = true
        task.wait(0.01)
        lightEmitter.Enabled = false
    end)()
end

image


bruh??

image

am i going crazy???

1 Like

If this is client-sided, replace FindFirstChild to WaitForChild.

1 Like

yooooo

i have some crazy BAD news

now it yields infinitely :frowning:

1 Like

Are you sure that you are passing the correct ViewModel?

first i clone the viewmodel out of ReplicatedStorage

then i set the parent of it to Workspace and pivot it to the player’s camera

then i pass it into the functions

image
image
image

unless i’m doing something stupid??

Nothing bad here.

The effects MIGHT be destroyed or removed by another script.

everything is entirely client sided and nothing gets deleted :slightly_frowning_face:

is this what happens after you take a 2 week break??

ugh…

Maybe add a wait(5) before the script starts to see if something needs to load?