local id = script.Parent.Animation
    local plr = game.Players.LocalPlayer
    local kb = script.Parent.keybind
    local UIS = game:GetService("UserInputService")

    --Play animation function
    local function playAnim()
        local char = plr.Character
        local humanoid = char:FindFirstChildOfClass("Humanoid")
    if humanoid then
            local animator = humanoid.Animator
            if animator then
                local animationTrack = animator:LoadAnimation(id)
                animationTrack:Play()
                while animationTrack.IsPlaying do
                    wait(0.1)
                    char.HumanoidRootPart.Anchored = true
                end
                char.HumanoidRootPart.Anchored = false            
                return animationTrack
            end
        end
    end

    --Character cap in keybind TextBox
    kb.Changed:connect(function()
        kb.Text = kb.Text:sub(1,1)
    end)

    --Custom keybind (that's where the error is)
    local function keybind(input)
        if input.UserInputType == Enum.KeyCode.kb.Text then
            playAnim()
        end
    end

    --Triggers
    UIS.InputBegan:Connect(keybind)
    script.Parent.Activated:Connect(playAnim)
    
    --test

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: