I was trying to use a custom keybind from a textbox in my gui and whenever I die, it says that it's Parent (An ImageLabel) is a nil value. I don't know why this is happening.

My code:

local g;
g = game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
	-- Line below errors --
	if Spells.Freeze.Bind.Text:len() == 1 or Spells.Explosion.Bind.Text:len() == 1 then 
		if input.KeyCode == Enum.KeyCode[Spells.Freeze.Bind.Text:upper()] then
			-- Code here
		end
	end
end)