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

How to Delete particle emitters inside character?

So i have particle emitters in the characters torso and i used findfirstchild to check if the particle emitters are in the players torso.

		if Torso:FindFirstChild("ParticleEmitter") == true then
			Torso:FindFirstChild("ParticleEmitter"):Destroy()
		end

Does it make a difference if the particle emitter is name "Aura"?

1 comment

0

Please make your question name more about the question. Your question is not about deleting particles, it is about checking them.

2 answers

Yes, using find first child, the text inside the quotations (referred to as a string) must be the name of the object.

if Torso:FindFirstChild("Aura") == true then
    Torso:FindFirstChild("Aura"):Destroy()
end


The only mistake in your code is that you are trying to use booleans with objects since it's not a bool value(I think it's a particle right??).You also didn't declare Torso.I would type my code like this: By the way, this is a Server Script in ServerScriptService or in Workspace

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character
	local Torso = char:FindFirstChild("Torso")  -- If it's in R15, I would type in HumanoidRootPart inside the quotation marks
	if Torso:FindFirstChild("Aura") then -- You check if the object exists or if its not nil
    		local aura = Torso:WaitForChild("Aura") 
		aura:Destroy()
		else
			print("Torso is nil and cannot find Aura")
	end
end)

I don't understand what you mean by "Aura" if it's nil or not. But if the Server Script does not work, Here is an alternative: This is a Local Script and put it in StarterGui Here is the alternative code:

local player = game.Players.LocalPlayer
local char = player.Character
local torso = char:FindFirstChild("Torso") -- If it's in R15, I would type in HumanoidRootPart inside the quotation marks
local aura = torso:WaitForChild("Aura")
if aura then
	aura:Destroy()
	else
		return print("Aura is nil")
end

If this answer helped then, Please accept, If you have any questions or if both of these scripts didn't work, please type in any question you want.

1 comment

0

Booleans with objects? FindFirstChild returns a boolean value whether it exists or not.

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