I have this code that if worked properly, should let a character have a new animation if pressed w, and it works, until you stop pressing w and then press it again, because the part of the script responsible for stopping the animation has no access to the animation being played, any way around this? Heres the script
local UIS = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Character = Player.Character Tool = script.Parent local PlayAnim Tool.Equipped:Connect(function(mouse) dog = true end) UIS.InputBegan:connect(function(input) if dog == true then if input.KeyCode == Enum.KeyCode.W then local Anim = Instance.new("Animation") Anim.AnimationId = "rbxassetid://3266940909" PlayAnim = Player.Character.Humanoid:LoadAnimation(Anim) PlayAnim:Play() end end end) UIS.InputEnded:connect(function(input) if input.KeyCode == Enum.KeyCode.W then local AnimationTracks = Player.Character:FindFirstChild("Humanoid"):GetPlayingAnimationTracks() local bot = AnimationTracks("Anim") bot:Stop() end wait(0.001) dog = false end)