Particles not emitting

my particles aren’t emitting inside my EmitVFX function. i enabled the VFX before emitting the particles and that works perfectly but the emit method isn’t working for me. thanks for any help! ^^

local VFX = {}
VFX.__index = VFX

local ServerScriptService = game:GetService("ServerScriptService")

local Server = ServerScriptService.Server
local Assets = Server.Assets
local VFXAssets = Assets.VFX

--[[
creates VFX + emit part.
@param name | the name of the VFX part with all the particle emitters, etc inside.
@param CF | cframe
@param parent | make sure its parented to a part.
]]

function VFX.new(name: string, CF: CFrame, parent: Instance?)
	local self = setmetatable({}, VFX)
	self.effects = {}
	
	local prefab
	
	for _, fx in ipairs(VFXAssets:GetDescendants()) do
		if not fx:IsA("BasePart") then continue end
		if fx.Name == name then
			prefab = fx
			break
		end
	end
	
	if not prefab then
		warn("VFX not found: ", name)
		return
	end

	if prefab:IsA("BasePart") then
		self.EmitPart = prefab:Clone()
		self.EmitPart.Name = prefab.Name.."_Emit"
		self.EmitPart.Anchored = true
		self.EmitPart.CFrame = CF
		self.EmitPart.Transparency = 1
		self.EmitPart.CanCollide = false
		self.EmitPart.Parent = parent or workspace

		for i, instance in ipairs(self.EmitPart:GetChildren()) do
			if instance:IsA("ParticleEmitter") then
				self.effects[instance.Name.."_"..i] = instance

			elseif instance:IsA("Attachment") then

				for effectIndex, effect in ipairs(instance:GetChildren()) do
					if effect:IsA("ParticleEmitter") then
						self.effects[instance.Name.."_"..effectIndex] = effect
					end
				end
			end
		end
	end

	return self
end


function VFX:EmitVFX(EmitCount: number?)
	if not self.effects then warn("VFX are missing: ", self.effects) end

	task.spawn(function()
		if self.effects then
			print(self.effects)
			for _, effect in pairs(self.effects) do
				if effect:IsA("ParticleEmitter") then
					local count = EmitCount or effect:GetAttribute("EmitCount") or effect.Rate
					effect:Emit(8)
				end
			end
		end
	end)
end

its a roblox bug or something and it happens to me too, emitting particles doesnt work unless i wait a bit, so i usually do task.wait(), but if i have multiple particles i need to emit i just use a task.delay with a time of like .0002 and it works fine

1 Like

it’s probably roblox bug or smth.
i replicated everything for a test and it works fine for me

that worked like a charm, thank u so much for ur help mercury!

1 Like

yeah it mustve been tbh. i appreciate the help thanks mate!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.