Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make this animation stop when the tool is UnEquipped?

Asked by
exarlus 72
6 years ago
Edited 6 years ago

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)

0
Mabye try to have the function that plays the animation within the function that turns on when the tool is equipped (tool.Equipped:connect(function() ninja_eaglegamer 61 — 6y
0
Try setting the variable playinganim out of the function and not nesting each function within each other. Earthkingiv 51 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I think i see the problem. You bundled up all your functions to stop the animation Try seperating them, see if that works

such as:

UIS.InputEnded:connect(function(input)
    --code
end)

tool.Unequipped:connect(function()
    --code
end)
Ad

Answer this question