Basically the animation wont stop when the tool is UnEquipped so i wanna figure out how to make it stop when the tool is UnEquipped.
tool = script.Parent
tool.Equipped:connect(function()
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
UIS.InputBegan:connect(function(input)--When a player has pressed LeftShift it will play the animation and it will set the normal walking speed (16) to 35.
if input.KeyCode == Enum.KeyCode.D then
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://1297032259'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
PlayAnim:Stop()
tool.Unequipped:connect(function()
PlayAnim:Stop()
end)
end
end)
end)

1 comment
thanks.