Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Keep particles locked on torso after death?

[USING R6 ANIMATIONS]

I have a button that, when touched by the player, attaches a particle effect to the player's torso.

However, when the player dies/respawns, the particles disappear. Is there any way to keep the particles attached to the player's torso, even after death?

My button script:

local Particles = script.Parent.Parent.ParticlesPart.ParticleEmitter

script.Parent.Touched:connect(function(Part)
local IsPar = Part.Parent.Torso:FindFirstChild("ParticleEmitter")
 
  if not IsPar then
    local particles = Particles:Clone()
    particles.Parent= Part.Parent.Torso
  else
    Part.Parent.Torso.ParticleEmitter:Destroy()
    local particles = Particles:Clone()
    particles.Parent= Part.Parent.Torso
  
  end

end)

Thanks in advance, MexheCo

1 answer

###The problem with your script is that you're wrongly assuming that an object named Torso will be a child of the touching part's parent, when this is not always the case. You must do checks.

local particles = script.Parent.Parent.ParticlesPart.ParticleEmitter

script.Parent.Touched:Connect(function(part)
    -- Switch to :Connect, :connect is deprecated
    local charOrWS = part.Parent
    
    if charOrWS:FindFirstChild("HumanoidRootPart") then
        if not charOrWS.HumanoidRootPart:FindFirstChild("ParticleEmitter") then
            particles:Clone().Parent = charOrWs.HumanoidRootPart
        else
            print("user already has particles!")
        end
    end
end)

###Just for error prevention. I won't be making the script that keeps the particles after death, since you did not attempt it.

1 comment

0

Understood, I will attempt and re-ask, if that is the correct way to go about things :) Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.