I’m trying to use a particle emitter for an impact VFX, But nothing is getting emitted when I play test. If I add a wait()or a task.wait() before or after the Emit line, it works, but it’s delayed and makes the effect look wrong when compared to the OG VFX. Has anyone experienced this before? Any help would be greatly appreciated!
Code Sample and RBXM of VFX:
local ImpactVfx = game:GetService("ReplicatedStorage"):WaitForChild("Fx").Part:Clone()
ImpactVfx.Anchored = true
ImpactVfx.Transparency = 1
ImpactVfx.CFrame = hit.CFrame
ImpactVfx.Parent = workspace
for i, v in ImpactVfx.Attachment:GetChildren() do
if v:IsA('ParticleEmitter') then
print('ok')
v:Emit(10)
end
end
--// cleanup
ImpactVfx:Destroy()
Don’t know why it’s doing that but try putting the emit function in a separate function and calling it with task.spawn no clue if it’ll work but that’s what I would try
I’m not much of a VFX scripter, so I’m not too familiar with ParticleEmitters. Something does concern me though. ParticleEmitter:Emit is not a yielding function, so just as fast as your loop activates your VFX, you destroy the parent instance of all the ParticleEmitters. This in turn destroys the ParticleEmitters. Where I’m weary is whether or not ParticleEmitters allows residue effects like Sounds do when they’re destroyed with Sound.PlayOnRemove
I completely glossed over that, but he’s right. You loop over the items so fast the parent is destroyed before you can actually see the effects. Just add a wait command before destroying