ParticleEmitter will not work in tool

I have a broom tool I’ve made, everything works fine but one problem, the particle emitter I have attached to one part of it (Bristle.Particle) will not activate when the tool.Activated goes off.

Local Script inside the tool:

local plr = game.Players.LocalPlayer
local Tool = script.Parent
local char = plr.Character or plr.CharacterAdded:Wait()
local idle = char:WaitForChild("Humanoid"):LoadAnimation(script.Idle)
local sweep = char:WaitForChild("Humanoid"):LoadAnimation(script.Sweep)
local particle = Tool.Bristle.Particle.Enabled

local canactivate = true

script.Parent.Equipped:Connect(function()
	game.ReplicatedStorage.ConnectM6D:FireServer(Tool.BodyAttach)
	char.Torso.ToolGrip.Part0 = char.Torso
	char.Torso.ToolGrip.Part1 = Tool.BodyAttach
	idle:Play()
end)

Tool.Unequipped:Connect(function()
	game.ReplicatedStorage.DisconnectM6D:FireServer()
	idle:Stop()
end)

Tool.Activated:Connect(function()
	if canactivate == true then
		sweep:Play()
		canactivate = false
		wait(1)
		particle = true
		wait(3)
		particle = false
		wait(1)
		sweep:Stop()
		canactivate = true
	end
end)
1 Like

What you are saying is a little unclear, but this is what I believe you need.

I believe this is because it is in the ‘Tool.Activated’ function therefore if the tool is not activated then the code won’t run again.

What I’m trying to achieve is that the PE will temporarily enable after the player clicks. But it doesn’t seem to emit any particles at all when I’m using the tool.

If you make the particles enabled inside of studio, can you see them then?

Yes. It works outside of whenever a player is actually using it, oddly enough

Does the sweep audio play when you activate the tool?

You need to set the Enabled property of the ParticleEmitter. When you get the property like this:

local particle = Tool.Bristle.Particle.Enabled -- Same as `local particle = false`

You don’t get a reference to Tool.Bristle.Particle.Enabled, you just get the value, which is either false or true. To set the Enabled property, you need to reference the Instance like so:

local ParticleEmitter = Tool.Bristle.Particle
ParticleEmitter.Enabled = true
task.wait(1)
ParticleEmitter.Enabled = false

Notice how this code uses a reference to the ParticleEmitter Instance, and doesn’t try to get a reference to the Enabled property of the ParticleEmitter.

1 Like