String works when typed out but not as variable

I downloaded an asset to help with twitch integration (the asset is called “twitcher”). During testing I used a call that uses a string to join a channel.

TwitchController.JoinRoom("TwitchChannel");

This works and I can join that channel. However, when I try to make it a variable as follows, it doesn’t work.

public void ConnectToTwitchFunc ()
{
    channelName = channelName.GetComponent<TextMeshProUGUI>().text;
    twitchCommands.GetComponent<TwitchRecieveCommands>().ChangeChannel(channelName);
}

public void ChangeChannel(string channelName)
{
    Debug.Log(":" + channelName + ":");
    TwitchController.JoinRoom(channelName);
}

I dont understand why it works as a string when I type it manually but doesn’t work when I use a variable.

If you are getting the text from a TMP Input Field then you shouldn’t use the underlying TextMeshProUGUI component as it’s got invisible characters in it.
Reference the TMP_InputField component instead.