I want the particle emitter’s enabled status to become false and then destroy itself later, however the particle emitter still plays and only destroys (without the particle stopping or becoming false first)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Combat.Remotes
local Start = Remotes.StrongStart
local End = Remotes.StrongEnd
local Effects = ReplicatedStorage.Combat.Effects
local function EffectStart(Character)
-- Clean up any existing effects
local existingEffect = Character:FindFirstChild("StrongEffect")
if existingEffect then
existingEffect:Destroy()
end
local existingWeld = Character:FindFirstChild("EffectWeld")
if existingWeld then
existingWeld:Destroy()
end
-- Create and configure the new effect and weld
local StrongEffect = Effects.StrongEffect:Clone()
local LeftArm = Character:WaitForChild("Left Arm")
local EffectWeld = Instance.new("Weld")
EffectWeld.Name = "EffectWeld"
EffectWeld.Part0 = LeftArm
EffectWeld.Part1 = StrongEffect
EffectWeld.C0 = CFrame.new(0, -1, 0)
StrongEffect.Parent = Character
EffectWeld.Parent = LeftArm
end
local function EffectEnd(Character)
local LeftArm = Character:WaitForChild("Left Arm")
local StrongEffect = Character:FindFirstChild("StrongEffect")
local EffectWeld = LeftArm:FindFirstChild("EffectWeld")
if StrongEffect and EffectWeld then
local Attachment = StrongEffect:FindFirstChild("Attachment")
if Attachment then
local Particle = Attachment:FindFirstChild("Particle")
if Particle and Particle:IsA("ParticleEmitter") then
-- Ensure the effect is turned off
Particle.Enabled.Value = false
end
end
-- Delay to allow the effect to complete
delay(5, function()
-- Check if the weld and effect still exist before destroying
if EffectWeld.Parent == LeftArm then
delay(4,function()
EffectWeld:Destroy()
end)
end
if StrongEffect.Parent == Character then
StrongEffect:Destroy()
end
end)
end
end
Start.OnServerEvent:Connect(function(Player)
local Character = Player.Character
print("Effect started")
EffectStart(Character)
end)
End.OnServerEvent:Connect(function(Player)
local Character = Player.Character
print("Effect ended")
EffectEnd(Character)
end)
–Here is a video of what is happening