How do I stop the animation when the tool gets unequipped?

A LocalScript can ONLY run if it is a Descendant of the Player Object. A ServerScript is replicated to the client.

If the sound is not a part of SoundService, mark its location exactly where it is located. Also, on the local equippedTool part, don’t add the extra char. Just look for the tool! Those would be the only fixes I have for you.

The sound is in the SoundService, but if I wanna play the sound locally shouldn’t I use a LocalScript?

Depends, ServerScript if it should be played to the whole server, LocalScript if it should be played only to the client.

It should only be played to the client. So should I paste the script in a LocalScript?

Yeah, handle the sound in a LocalScript.

Only the sound? How would I do that?

Have a remoteevent, and set it off when you want the sound, then hook it up to an event, and play the sound like that.

Bruh, sounds complex. Can’t I just paste the code in a localscript? :joy:

Maybe a silly question, because I don’t know your setup, but couldn’t you just unequip it before you removed it? Under what condition might the tool be removed that is not controlled?

The player touches a part with an equipped tool. If its equipped it gets removed, if not equipped it wont get removed.

I know you have already marked this as solved, and checking for tool.Parent is something I have and do use also. However, just to give an alternative solution, you could (using the same remote event that most tools communicate between client and server) have the part touched, just send an event to the tool, (or set a flag instance on the tool, which the tool monitors) to tell the tool to stop its animation and destroy itself.

local destroyFlag = tool:FindFirstChild("DestroyFlag") -- this would be a BoolValue instancce
destroyFlag.Changed:Connect(function()
if destroyFlag.Value == true then
	if LoadedAnim then 
		LoadedAnim:Stop()
	end
game.Debris:Add(tool,1) --I see a lot of the Roblox tools add this, its seems redundant, but I put it anyway
tool:Destroy()
end
end

then the block that removes the tool, would just do…

if tool:FindFirstChild("DestroyFlag") then
tool.DestroyFlag.Value = true
end

This keeps you from having to start a loop in a new thread

That would be another solution. However, I fixed everything now so it should work.
But I got another problem, maybe you are able to help me with that?

local Particles = script.Parent.Particles.Smoke
wait(0.2)
Particles.Enabled = false

script.Parent.Touched:Connect(function(hit)
	print("moin")
	local Sound = game.SoundService.FirstTask
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	local lemon = player.Backpack:FindFirstChild("Wheelbarrow") or player.Character:FindFirstChild("Wheelbarrow") 
	if lemon then
		local char = player.Character
		local equippedTool = char:FindFirstChildWhichIsA("Tool")
		if equippedTool then
			local ArrowEvent = game.ReplicatedStorage.ArrowEvent
			ArrowEvent:FireAllClients(script.Parent, false)
			lemon:Destroy()
			Particles.Enabled = true
			wait(0.8)
			Particles.Enabled = false
			
		end
	end
end)

The script is inside a part, if you touch the part the tool gets removed and the particles should be enabled for 0.8 seconds. The problem is they are enabled by default, I disabled them in studio and in line 2 of the script, but it doesn’t work. When you touched the part the first time and the tool got removed, then it works perfect. But idk why the particles are enabled by default…

If script.Parent is the part, then script.Parent.Particles is … a folder or a model, containing the instance ‘Smoke’ ?

Make sure you have the particle parented to a valid object, such as a BasePart or Attachment.
Also make sure you do not have multiple particles with the same name.

You could also debug it a bit and put a script somewhere that detects when the particle’s enabled is changed or not, and print you a message, so you know if another script is changing the enabled state.

Hope you solve it, I know that sort of thing is very frustrating.

image
The particles are a parent of the part, like the script.

If you are setting the enabled == false in studio, but when you start a game, it is enabled == true then either some code in your game is creating a new Smoke effect, and your script is detecting the new one, or some code in your game is setting enabled == true when it should not.

To check, you could always open a new empty studio project, and put in that part, and see if you can disable it, or see if there are multiples of the particle. That’s all you can really do, is check the explorer panel in a running studio game, and see what is happening or put breakpoints or print statements to show you the states of the particle effect. Or just do a script search for .Enabled and see what all scripts are setting Enabled == true and on what objects. Sorry there is no real easy answer for this.

Okay thank you, but there is no way that there is another script which enables the same particle.

You should create a new post and ask for help on this specific problem, you might get more help than what I can give. Sorry

I already did. Nobody answered yet :confused: