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

ParticleEmitter not activating when parent tool is activated?

I'm fairly new to scripting, and I've spent the last half hour trying to figure out why my code won't work. Basically, what the script does, is it sets a ParticleEmitter's state to enabled when the parent tool is activated. I cannot figure out how to get this to work. Here's the code:

BlowTorchFlame = game.StarterPack.Blowtorch.Handle.ParticleEmitter
BlowTorch = game.StarterPack.Blowtorch

BlowTorchFlame.Enabled = false

local function onActivate()
 BlowTorchFlame.Enabled = true
end

BlowTorch.Activated:connect(onActivate)

Any help would be greatly appreciated.

2 comments

0

Where is this script located?

0

Inside of the tool called "Blowtorch" in the starterpack.

1 answer

✓ Accepted answer

Always remember which Tool you're making changes to

If you look at the top few lines of your code, you actually created a reference to the Blowtorch in the StarterPack, not the Player's BackPack. I wrote a (fixed?) version below, feel free to ask me any questions you might have about it.

wait()
Players = game:GetService("Players")
LocalPlayer = Players.LocalPlayer
BackPack = LocalPlayer.BackPack

BlowTorch = BackPack.Blowtorch
BlowTorchFlame = BlowTorch.Handle.ParticleEmitter

BlowTorchFlame.Enabled = false

function onActivate()
	BlowTorchFlame.Enabled = true
end

BlowTorch.Activated:connect(onActivate)

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