im not sure whats wrong

local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")
local AnimationId = 'rbxassetid://4397242217'
local Key = 'W'
 
UserInputService.InputBegan:Connect(function(Input, ItTyping)
    if ItTyping then return end
    if Input.KeyCode == Enum.KeyCode[Key] then
        local Animation = Instance.new("Animation")
        Animation.AnimationId = AnimationId
        local LoadAnimation = Humanoid:LoadAnimation(Animation)
        LoadAnimation:Play()
    Animation.Parent = Character
    Animation.Name = "Animation"
    end
end)
 
UserInputService.InputEnded:Connect(function(Input, IsTyping)
    if IsTyping then return end
        if Input.KeyCode == Enum.KeyCode[Key] then
        if Character:FindFirstChild("Animation") == true then
            Humanoid:LoadAnimation(Character:FindFirstChild("Animation")):Stop()
        end
    end
end)

1 comment

0

If there isn't any errors then your problem could be that there is another animation that is overriding your animation