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.
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?
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.
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.