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
Try changing all these FindFirstChild to WaitForChild In the whole script.
Unless the FindFirstChild is being used to test for nil. It’s just as fast or it will wait.
If there is an error, it’s not there when you’re calling this… that’s the problem.