I have a staff that shoots projectiles, which have particles. When the projectile touches something, it gets destroyed. The problem is that destroying the projectile gets rid of all the existing particles, but I want these existing particles to linger. I tried to fix this by reparenting the ParticleEmitter to a dummy part, but it still does not linger.
I’ve tested it and found that:
Disabling a particle emitter does NOT remove any existing particles.
Reparenting a particle emitter doesn’t do that either.
My code (the most relevant part is the destroyProjectile function):
remotes.ReplicateStaffAttack.OnServerEvent:Connect(function(plr, mouseHit)
local staff = plr.Character.WeaponReference.Value
local itemModule = require(repStorage.Items.Stats[staff.Name])
local alreadyHit = {}
staff["StaffAttack"..math.random(1,2)]:Play()
local projectile = Instance.new("Part")
projectile.Shape = Enum.PartType.Ball
projectile.Material = Enum.Material.Neon
projectile.Color = Color3.fromRGB(0, 170, 255)
projectile.Size = Vector3.new(0.9, 0.9, 0.9)
projectile.Anchored = false
projectile.CanCollide = false
projectile.Parent = workspace
staff.AttackParticleAttachment.AttackParticles:Emit()
local projParticles = staff.ProjectileParticles:Clone()
projParticles.Parent = projectile
projParticles.Enabled = true
local function destroyProjectile()
local dummyPart = Instance.new("Part", workspace)
dummyPart.Name = "DummyPart"
projParticles.Enabled = false
projParticles.Parent = dummyPart
dummyPart.Position = projectile.Position
dummyPart.CanCollide = false
dummyPart.Transparency = 1
dummyPart.Anchored = true
dummyPart.Size = Vector3.new(0.1,0.1,0.1)
projParticles.Parent = dummyPart
game:GetService("Debris"):AddItem(dummyPart, 2)
projectile:Destroy()
end
local p0 = staff.Position
local p2 = mouseHit
local p1 = (p0 + p2) / 2 + Vector3.new(0, 5, 0)
projectile.Touched:Connect(function(hit)
local target = hit.Parent
if not game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("Humanoid") and not table.find(alreadyHit, target) then
table.insert(alreadyHit, target)
local dmg = itemModule["BaseDamage"]
dealDamage(plr, dmg, target)
destroyProjectile()
end
end)