As the title says, the particleEmitter effects I have for my ability doesn’t seem to emit at the very first ability usage, but for the rest usages after that it works normally. I tried adding wait() before emit() but still doesnt work. Below is how I clone and emit particle in client on ability trigger:
-- In VFX Local script
local BlinkFX_new = VFX.PostBlinkVFX:Clone()
BlinkFX_new.Position = newPos
BlinkFX_new.Parent = workspace.Fx
for _, particle in pairs(BlinkFX_new:GetDescendants()) do
if particle:IsA("ParticleEmitter") then
wait()
particle:Emit(particle:GetAttribute("EmitCount"))
end
end
Debris:AddItem(BlinkFX_new, 3)
I believe it might just be that its not retrieving the emitCount Attribute right, so just ensure that it is set right. I made a slightly better version with a fallback value -
for _, particle in ipairs(BlinkFX_new:GetDescendants()) do
if particle:IsA("ParticleEmitter") then
local emitCount = particle:GetAttribute("EmitCount") or 5 -- fallback value
particle:Emit(emitCount)
end
end
Was gonna say this but never did my research enough to tell that pairs & ipairs are deprecated, either way it’s not like using ipairs is gonna make the instances magically appear lol.
Ok I tried adding wait(5) before emit and it works, seems like the problem is it is not cloned fast enough. But I dont think adding a wait time before emit is a good solution because that introduces some noticable delay. Are there any other solutions? Should I pre-clone every FXs when character loads in and then move and activate it when needed etc…?
Okayy so we found the problem
I recommend cloning and debris:AddItem() in the Server and then sending the particles to the client to emit them. Kinda like that:
remoteEvent.OnClientEvent:Connect(function(vfx)
for _, particle in pairs(vfx:GetDescendants()) do
if particle:IsA("ParticleEmitter") then
particle:Emit(particle:GetAttribute("EmitCount"))
end
end
end)
For the caster player i planned to emit locally on his client as soon as he presses the ability key for the instant feel, if i clone in server and send to client to emit, even the caster will feel a slight delay which i want to prevent. Any solution?
The Effects should be replicating to all clients to begin with, no need for the server to be creating assets.
If the user just sets up Networking events for Client & Server on the attacks it should work like a charm and be super smooth, with the server controlling, of course, server properties.
No matter what i try the problem still persist, and upon further testing it seems that it is random, where sometimes it does work the first go but sometimes it just doesnt, as seen in this vid. Maybe this is just a bug in the studio? i just hope this doesnt happen in live game. I even tried ObjectPooling, using PreloadAsync() etc… nothing works, it is just completely random