How to check if part has smoke(child)?

I wanna create part with smoke on it with Instance.new and this is my script

    DefaultPart.Name = "Default part"
	DefaultPart.Transparency = 1
	DefaultPart.CanCollide = false
	DefaultPart.CanTouch = false
	DefaultPart.Anchored = true
	DefaultPart.Size = Vector3.new(0.645, 0.645, 0.645)
	DefaultPart.Position = char.RightUpperLeg.Position 
	DefaultPart.Parent = workspace.PartsHolder
	print("part was created")

	DefaultParticle.Name = "Default particle"
	DefaultParticle.Color = Color3.new(color)
	DefaultParticle.Opacity = 2
	DefaultParticle.RiseVelocity = 2
	DefaultParticle.Size = 2
	DefaultParticle.TimeScale = 1
    DefaultParticle.Parent = game.Workspace.PartsHolder["Default part"]

This script activated per click and the problem is that its create smoke on part that already has smoke. i found solution with local DefaultParticle = Instance.new("Smoke",DefaultPart) but i dont think thats its a right solution. First question how to check if part already has Smoke, second question is there any others better ideas how to do this?

You would use FindFirstChild (or FindFirstChildOfClass) in this case

if Part:FindFirstChildOfClass("Smoke") then
 -- code
end
if Part:FindFirstChildWhichIsA("Smoke") then -- I dont Remember the Super Class
 -- code
end
if Part:FindFirstChild("Smoke") then
 -- code
end
2 Likes

If you want to check for smoke, you should loop through the part or entity you want to check with :GetDescendants(). then you can check if its a smoke with :IsA(“Smoke”)

Or do the above…

Although this is Valid, when doing this, you can accidentally delete something which isn’t Intended

Mainly because you are looking to the Hierarchy within the Part for smoke, and can accidentally delete a Detail of some sort. (If i said that correctly)

Hm i dont really understand how to

I try a lot of things with it but nothing worked and smoke still spawns only in one part. I dont really understand how to do this because this helps me to find part with smoke but i need to find part without smoke and add it into this part.

So use the not operator. This will flip the condition, so:

if not Part:FindFirstChildWhichIsA("Smoke") then -- I dont Remember the Super Class
 -- code will run if there is no smoke
end
1 Like

Still dont really understand how to do it. I try it with “if not” and just “if” and etc but still have the same problem(on picture)
image

Maybe someone can say me where i need to place “FindFirstChildWhichIsA” and give me a quick-explanation why and where it need to stay? Here is my script:

local module = {}

module.Particle = function(opacity,risevelocity,size,timescale,color)
	
	local player = game.Players.LocalPlayer
	local char = player.Character 
	
	local DefaultPart = Instance.new("Part")
	local DefaultParticle = Instance.new("Smoke")
	local PartsHolder = game.Workspace.PartsHolder
		
	DefaultPart.Name = "Default part"
	DefaultPart.Transparency = 1
	DefaultPart.CanCollide = false
	DefaultPart.CanTouch = false
	DefaultPart.Anchored = true
	DefaultPart.Size = Vector3.new(0.645, 0.645, 0.645)
	DefaultPart.Position = char.RightUpperLeg.Position 
	DefaultPart.Parent = workspace.PartsHolder
	print("part was created")
	
	DefaultParticle.Name = "Default particle"
	DefaultParticle.Color = Color3.new(color)
	DefaultParticle.Opacity = opacity
	DefaultParticle.RiseVelocity = risevelocity
	DefaultParticle.Size = size
	DefaultParticle.TimeScale = timescale
	DefaultParticle.Parent = game.Workspace.PartsHolder["Default part"]
	print("particle was created")

	wait(10)
	DefaultPart:Destroy()
	
end

return module

Part and smoke spawning once per click and i dont understand how to do that smoke will spawn only on part that doesn`t have smoke in it

Change that line in your script to

DefaultParticle.Parent=DefaultPart
1 Like

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