Unsure how to stop tool idle animation [SOLVED]

I would recommend using a touch event like so (in the server) parented to the tool:

script.Parent.Touched:Connect(function(part)
if part.Parent ~= script.Parent.Parent:WaitForChild("HumanoidRootPart") and part.Parent:WaitForChild("HumanoidRootPart") then
script.Parent:Destroy()
end
end)

This is already done on the server script, heres a picture:

the problem now is that once the tool is deleted, the idle tool animation still plays and doesn’t go back to the normal idle animation. This is why I’m asking how could I go about this to be able to stop the idle animation when I don’t have access to it on the server script, nor on the activation function in the client script. I only have it on the equipped function in the client script.

It could have something to do with you playing an animation right before deleting the tool. Try adding task.wait(1) after playing the hit animation.

Didn’t work. Heres a picture of the activation function in the client script that plays the hit animation incase you need it.

image

Try moving that event to the server and seeing what happens.

Do you mean the event from the previous script I showed you? because that is in the the server, the activation script that I just showed fires the remote event to that server script.

Which script fires to which script?

Just put this function in the same script

local AnimationTrack = nil --This later gets set to the animation when the tool is equipped 
Tool.Removing:Connect(function()
if AnimationTrack then
AnimationTrack:Stop()
end
end)

You need to load the animation and set a variable outside the equip function to do this
I would provide full code but I’m on mobile right now so :person_shrugging:

Old post: (for Unequipped)

I forget if LocalScripts run in player.Backpack or not, but if they don’t, either connect the AnimationTrack:Stop() in a Tool.Unequipped event or copy paste the code into a Script and set its run context to Client (So that it can basically run anywhere)

I’d recommend copying code so that it’s easier to explain where edits go.

You could do this after line 7:

local unequipped
local destroyed
destroyed = script.Parent.Destroying:Once(function()
    AnimationTrack:Stop()
    AnimationTrack = nil
    if destroyed and destroyed.Connected then destroyed:Disconnect() end destroyed = nil
    if unequipped and unequipped.Connected then unequipped:Disconnect() end unequipped = nil
end)
unequipped = script.Parent.Unequipped:Once(function()
    AnimationTrack:Stop()
    AnimationTrack = nil
    if destroyed and destroyed.Connected then destroyed:Disconnect() end destroyed = nil
    if unequipped and unequipped.Connected then unequipped:Disconnect() end unequipped = nil
end)

I tried this and it didn’t work, thanks for trying to help though!

I’m trying this right now, I’ll let you know how it goes.

Solved the problem a different way. I tried many methods and it didn’t seem to work so I tried something different. When the tool is used it would be parented to a folder where anything that enters that folder will destroy it. The reason why I did this instead is because I noticed that it actually stopped the tool idle animation when I put the tool in a different area compared to just destroying it. Not sure why it didn’t work when I was destroying the tool before but it may have something to do with the response time, not sure. But thank you for everyone that tried to help, I appreciate it! :slight_smile:

1 Like

In the same script. just delete your:

script.Parent.Unequipped:Wait()
AnimationTrack:Stop()

and replace it to the one that I said. I do this and it works fine for me

This is unnecessary honestly, just do the simple .Removing function and stop the animation inside of it, there is nothing else to do.

1 Like

Yeah that works but using the .Removed function saves wayy more time and performance

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