1

# How do I stop the animation when the tool is unequipped?

Edited 3 years ago
local Player = game:GetService("Players").LocalPlayer
---
local Tool = script.Parent
---
local Handle = Tool:WaitForChild("Handle")
--
local Character = Player.Character or Player.CharacterAdded:Wait()
--
local Mouse = game.Players.LocalPlayer:GetMouse()
--
local Humanoid = Character:WaitForChild("Humanoid")
--

------
function GunDown()
Anim:Play()
script.Parent.LocalScript.Disabled = true
script.Parent.GunScript.Disabled = true
end

function GunUp()
Anim:Stop()
script.Parent.LocalScript.Disabled = false
script.Parent.GunScript.Disabled = false
end
------

Tool.Unequipped:Connect(function()
Anim:Stop()
script.Parent.GunScript.Disabled = false
script.Parent.LocalScript.Disabled = false
StopAnim1:Stop()
StopAnim2:Stop()
StopAnim3:Stop()
end)

Mouse.KeyDown:connect(function(key)
key = key:lower()
if key == "f" then
GunDown()
end

if key == "g" then
GunUp()
end
end)


Hello, I am trying to script a gundown script, this is a local script in a tool and it disables the scripts that lets the player shoot, but the issue is that the Animation isn't stopping when the tool is unequipped.

0
IrishFix 124
3 years ago

Im not entirely sure but in the parameters of the anim:Stop() you could put a fade time to make sure it does it, like:

Anim:Stop(0.5)

Hope i helped - Irish